"""The Python checks, figure scripts and certificate programs of the paper, bundled in one file. Run python3 scripts.py to write them out under the current directory with their original names (d5/, slice/ included), then run each one as described in its own docstring.""" FILES = { 'any_exterior.py': '"""Checks of the bound for every exterior (Proposition prop:anyexterior and\nCorollary cor:anyexterior of the forest paper, Sec. ssec:largefields).\n\nFor boxes [0,l]^4 with l = 2, ..., 6 this program\n\n (a) enumerates the inner links and plaquettes and checks the counts\n n_L = 4l(l-1)^3, n_P = 6l^2(l-1)^2, the 24(l-1)^3 inner plaquettes\n that contain a boundary link, and that every plaquette containing an\n inner link is inner;\n (b) checks that the unit cubes x + [0,1]^4 with x in {1,...,l-2}^4 have\n only inner plaquettes, that l^4 - (l-2)^4 unit cubes meet the\n boundary, and that a plaquette lies in at most four unit cubes;\n (c) checks the constants: 24 pi^3 < e^7, the Haar mass of the cap of\n angle t in SU(2) against 8t^3/(3 pi^3) by quadrature, and the\n inequality 6x + 31 <= e^(x/4)/128 for x >= 44 on a fine grid and at\n x = 44 exactly in rational arithmetic, with the final bracket 1/64.\n\nUsage: python3 any_exterior.py\n"""\n\nimport itertools\nimport math\nfrom fractions import Fraction as Fr\n\nD = 4\nchecks = []\n\n\ndef check(name, ok):\n checks.append(bool(ok))\n print(("PASS " if ok else "FAIL ") + name)\n\n\ndef unit(i):\n return tuple(1 if k == i else 0 for k in range(D))\n\n\ndef add(a, b):\n return tuple(p + q for p, q in zip(a, b))\n\n\ndef box(l):\n def link_bd(x, m):\n return any(x[i] in (0, l) for i in range(D) if i != m)\n\n def plaq_bd(x, m, n):\n return any(x[i] in (0, l) for i in range(D) if i not in (m, n))\n\n def plinks(x, m, n):\n return [(x, m), (add(x, unit(m)), n), (add(x, unit(n)), m), (x, n)]\n\n sites = list(itertools.product(range(l + 1), repeat=D))\n links = [(x, m) for x in sites for m in range(D) if x[m] < l]\n inner = {e for e in links if not link_bd(*e)}\n plaqs = [(x, m, n) for x in sites for m in range(D) for n in range(m + 1, D)\n if x[m] < l and x[n] < l]\n ip = [p for p in plaqs if not plaq_bd(*p)]\n bp = sum(1 for p in ip if any(link_bd(*e) for e in plinks(*p)))\n closed = all(not plaq_bd(*p) for p in plaqs if any(e in inner for e in plinks(*p)))\n check(f"(a) l={l}: n_L={len(inner)}, n_P={len(ip)}, boundary-link plaquettes {bp}, "\n f"plaquettes with an inner link are inner",\n len(inner) == 4 * l * (l - 1) ** 3 and len(ip) == 6 * l * l * (l - 1) ** 2\n and bp == 24 * (l - 1) ** 3 and closed)\n cubes = list(itertools.product(range(l), repeat=D))\n meet = sum(1 for x in cubes if any(c in (0, l - 1) for c in x))\n ok = True\n incid = {}\n for x in cubes:\n for m in range(D):\n for n in range(m + 1, D):\n for o in itertools.product((0, 1), repeat=D):\n if o[m] or o[n]:\n continue\n p = (add(x, o), m, n)\n incid[p] = incid.get(p, 0) + 1\n if not any(c in (0, l - 1) for c in x):\n ok &= not plaq_bd(*p)\n check(f"(b) l={l}: {meet} unit cubes meet the boundary, interior cubes have inner "\n f"plaquettes, at most {max(incid.values())} cubes per plaquette",\n meet == l ** 4 - (l - 2) ** 4 and ok and max(incid.values()) <= 4)\n\n\ndef constants():\n check("(c) 24 pi^3 < e^7", 24 * math.pi ** 3 < math.exp(7))\n ok = True\n for t in (0.01, 0.05, 0.1, 0.25):\n n = 20000\n h = t / n\n mass = sum((2 / math.pi) * math.sin((k + 0.5) * h) ** 2 * h for k in range(n))\n ok &= mass >= 8 * t ** 3 / (3 * math.pi ** 3)\n check("(c) Haar mass of the cap of angle t is at least 8t^3/(3 pi^3)", ok)\n # e^11 > (8/3)^11 since e > 8/3\n check("(c) at x = 44: 6x + 31 = 295 <= (8/3)^11/128 < e^11/128",\n Fr(8, 3) ** 11 / 128 >= 295)\n ok = all(6 * x + 31 <= math.exp(x / 4) / 128 for x in (44 + k / 100 for k in range(20000)))\n check("(c) 6x + 31 <= e^(x/4)/128 on [44, 244]", ok)\n check("(c) 1/32 - 1/128 - 1/128 = 1/64", Fr(1, 32) - Fr(2, 128) == Fr(1, 64))\n check("(c) 48 beta/l <= beta^(1/4)/128 when l >= 6144 beta^(3/4)", Fr(48, 6144) == Fr(1, 128))\n\n\nif __name__ == "__main__":\n for l in range(2, 7):\n box(l)\n constants()\n print(f"{sum(checks)} of {len(checks)} checks passed")\n', 'block_gauge.py': '"""Block-rooted axial gauge with full-block conditioning: the counts behind the\nuniform gap and the localisation of the block-constrained cube responses.\n\nBlocks are the 2-cubes 2y + {0,1}^4. A link (x, mu) with offset o = x mod 2 is a\ntree link when o_mu = 0 and o_nu = 0 for every nu > mu. For a coarse link (y, mu)\nthe full-block average V_{y,mu} is the mean, over the 16 straight paths of length\ntwo in direction mu starting in the block, of the sum of the field along the path.\n\nParts:\n (A) tree: 15 links per block, a spanning tree of the block; 17 active intra-block\n links, 32 inter-block links, 49 classes.\n (B) chain: every active intra-block link is a signed sum of k <= 3 plaquette\n curvatures of its block (all other links of the plaquettes being tree links\n or earlier links of the chain), and every plaquette carries load <= 8.\n (C) faces: the 12 face plaquettes of a coarse link are the 12 edges of the\n transverse 3-cube; V = (1/8) sum(face links) + (S_y + S_{y+e_mu})/16; every\n intra link gets weight 9/2 + 1 = 11/2 when the face bounds are summed.\n (D) constants of the saddle-point system: lambda_min(B B^T) >= 1/16, row sums\n of |H| at most 24, of the scaled system at most 192 (s = 96), and the\n resulting localisation constants.\n (E) exact linear algebra in floating point (comparison only): the bulk gap of\n the constrained symbol and the gap and responses on the cubes n = 2, 4.\n (F) the invisible line class of the line-field gauge (face averages, n = 4).\nRun: python3 block_gauge.py. Needs numpy and scipy."""\nimport itertools, math, sys\nfrom fractions import Fraction as Fr\nimport numpy as np\n\nE = np.eye(4, dtype=int)\nOFFS = list(itertools.product(range(2), repeat=4))\nok = []\n\ndef check(name, cond):\n ok.append(bool(cond)); print((\'ok \' if cond else \'FAIL\'), name)\n\ndef tree(o, mu):\n o = [c % 2 for c in o]\n return o[mu] == 0 and all(o[nu] == 0 for nu in range(mu + 1, 4))\n\n# (A)\ntl = [(o, mu) for o in OFFS for mu in range(4) if tree(o, mu)]\nparent = {o: o for o in OFFS}\ndef find(a):\n while parent[a] != a: a = parent[a]\n return a\ncyc = False\nfor (o, mu) in tl:\n a, b = find(o), find(tuple(np.array(o) + E[mu]))\n if a == b: cyc = True\n parent[a] = b\ncheck(\'(A) 15 tree links forming a spanning tree of the block\',\n len(tl) == 15 and not cyc and len({find(o) for o in OFFS}) == 1)\nintra = [(o, mu) for o in OFFS for mu in range(4) if o[mu] == 0 and not tree(o, mu)]\ninter = [(o, mu) for o in OFFS for mu in range(4) if o[mu] == 1]\ncheck(\'(A) 17 active intra-block links, 32 inter-block links, 49 classes\',\n len(intra) == 17 and len(inter) == 32 and len(intra) + len(inter) == 49)\n\n# (B)\nload, kmax = {}, 0\nfor (z, mu) in intra:\n ones = [r for r in range(mu + 1, 4) if z[r] == 1]\n kmax = max(kmax, len(ones)); x = list(z)\n for nu in sorted(ones, reverse=True):\n x[nu] = 0\n xa = np.array(x)\n # plaquette at x in the plane (mu, nu): (x,mu) earlier, (x,nu), (x+e_mu,nu) tree\n assert tree(tuple(x), nu) and tree(tuple(xa + E[mu]), nu)\n key = (tuple(x), mu, nu); load[key] = load.get(key, 0) + len(ones)\n assert tree(tuple(x), mu)\ncheck(\'(B) chains of length <= 3 ending in tree links\', kmax == 3)\ncheck(\'(B) plaquette load at most 8 (so I <= 8 Q_in)\', max(load.values()) == 8)\n\n# (C)\ngood = True\nfor mu in range(4):\n face = [o for o in OFFS if o[mu] == 1]\n pl = [(o, nu) for o in face for nu in range(4) if nu != mu and o[nu] == 0]\n edges = {frozenset([o, tuple(np.array(o) + E[nu])]) for (o, nu) in pl}\n good &= len(pl) == 12 and len(edges) == 12\n coef = {}\n for o in OFFS:\n for k in range(2):\n y = np.array(o) + k * E[mu]\n key = (\'F\', tuple(y)) if y[mu] == 1 else (\'I\', tuple(y % 2), int(y[mu] // 2))\n coef[key] = coef.get(key, 0) + Fr(1, 16)\n good &= all(v == (Fr(1, 8) if k[0] == \'F\' else Fr(1, 16)) for k, v in coef.items())\n good &= sum(1 for k in coef if k[0] == \'F\') == 8 and sum(1 for k in coef if k[0] == \'I\') == 16\ncheck(\'(C) 12 face plaquettes = 12 edges of the 3-cube; V = (1/8)sum F + (S+S\\\')/16\', good)\nw = {}\nfor mu in range(4):\n for o in OFFS:\n for nu in range(4):\n if nu == mu or o[nu] != 0: continue\n if o[mu] == 1: # (x,nu) in block y, used by face (y,mu)\n w[(o, nu)] = w.get((o, nu), 0) + Fr(3, 2)\n else: # (x+e_mu,nu) in block y+e_mu, used by face (y,mu)\n w[(o, nu)] = w.get((o, nu), 0) + Fr(3, 2)\n for o in OFFS:\n if o[mu] == 0:\n w[(o, mu)] = w.get((o, mu), 0) + 2 * Fr(1, 2)\ncheck(\'(C) every intra link has total weight 11/2\', set(w.values()) == {Fr(11, 2)})\na = Fr(1, 1) / (Fr(13, 2) * 8)\ncheck(\'(C) gap constant 1/52\', a == Fr(1, 52))\n\n# (D)\ns, h, b = 96, 24, Fr(1, 16)\nx1 = 1 / (s * math.sqrt(float(b))) # ||x_1|| per unit ||g\'||\nxn = math.hypot(52, 52 * h * x1 + x1) # ||x|| for ||f||^2 + ||g\'||^2 = 1\nyn = (1 + h * xn) / (s * math.sqrt(float(b)))\nM0 = math.hypot(xn, yn)\nS = max(h + s * Fr(1, 8), 2 * s)\nR = 1 # midpoints of links sharing a plaquette, and of a row and its links, are within distance 1\nlam = math.log(1 + 1 / (2 * float(S) * M0)) / R\nq = math.exp(-2 * lam)\nsum3 = q * (1 + 4 * q + q * q) / (1 - q) ** 4; sum1 = q / (1 - q) ** 2\nW = 4 * math.exp(2 * lam) * (1 + 64 * sum3 + 16 * sum1)\nrhs = 6 * math.sqrt(3) + s / 16\nM = math.sqrt(W) * 2 * M0 * math.exp(R * lam) * rhs\nprint(f\' M0 <= {M0:.2f}, S = {S}, lambda = {lam:.4e}, sqrt(W) = {math.sqrt(W):.3e}, M <= {M:.3e}\')\ncheck(\'(D) M0 <= 105, S = 192, lambda >= 2.4e-5, ||u_j||_1 <= 10^14\',\n M0 <= 105 and S == 192 and lam >= 2.4e-5 and M <= 1e14)\n\nmid = lambda x, mu: np.array(x, float) + 0.5 * E[mu]\ndmax = 0\nfor mu in range(4):\n c = 0.5 * np.ones(4) + E[mu]\n for o in OFFS:\n for k in range(2):\n y = np.array(o) + k * E[mu]\n dmax = max(dmax, np.abs(mid(y, mu) - c).max())\nfor o in OFFS:\n x = np.array(o)\n for mu in range(4):\n for nu in range(mu + 1, 4):\n ms = [mid(x, mu), mid(x + E[mu], nu), mid(x + E[nu], mu), mid(x, nu)]\n dmax = max(dmax, max(np.abs(p - q).max() for p in ms for q in ms))\ncheck(\'(D) R = 1: links of a plaquette, and a row and its links, within distance 1\', dmax <= 1)\n\n# (E) floating-point comparison\nimport scipy.sparse as sp\ndef block_rows(L=2):\n links = [(o, mu) for o in OFFS for mu in range(4)]\n act = [l for l in links if not tree(*l)]; idx = {l: i for i, l in enumerate(act)}\n def red(x, mu):\n x = np.array(x); return (tuple(x % 2), mu), tuple(x // 2)\n P = []\n for o in OFFS:\n x = np.array(o)\n for mu in range(4):\n for nu in range(mu + 1, 4):\n r = []\n for (y, m, sg) in [(x, mu, 1), (x + E[mu], nu, 1), (x + E[nu], mu, -1), (x, nu, -1)]:\n l, c = red(y, m)\n if l in idx: r.append((idx[l], c, sg))\n P.append(r)\n C = []\n for mu in range(4):\n r = {}\n for o in OFFS:\n for k in range(2):\n l, c = red(np.array(o) + k * E[mu], mu)\n if l in idx: r[(idx[l], c)] = r.get((idx[l], c), 0) + 1 / 16\n C.append([(i, c, v) for (i, c), v in r.items()])\n return P, C, len(act)\nP, C, nA = block_rows()\ndef sym(rows, q):\n Mx = np.zeros((len(rows), nA), complex)\n for i, r in enumerate(rows):\n for (j, c, v) in r: Mx[i, j] += v * np.exp(1j * np.dot(q, c))\n return Mx\nbest = 9\nfor qq in itertools.product(range(4), repeat=4):\n q = 2 * np.pi * np.array(qq) / 4\n D = sym(P, q); H = D.conj().T @ D; B = sym(C, q)\n u, sv, vh = np.linalg.svd(B); N = vh[(sv > 1e-10).sum():].conj().T\n best = min(best, np.linalg.eigvalsh(N.conj().T @ H @ N)[0])\nprint(f\' bulk min lambda_min(H_c) on the 4^4 grid = {best:.12f}\')\ncheck(\'(E) bulk constrained gap >= 1/52\', best >= 1 / 52)\n\ndef cube(n):\n inV = lambda x: all(0 <= c < n for c in x)\n V = [(x, mu) for x in itertools.product(range(n), repeat=4) for mu in range(4) if not tree(x, mu)]\n vi = {l: i for i, l in enumerate(V)}; ext = {}\n def var(x, mu):\n x = tuple(int(c) for c in x)\n if tree(x, mu): return None\n if (x, mu) in vi: return (\'V\', vi[(x, mu)])\n ext.setdefault((x, mu), len(ext)); return (\'E\', ext[(x, mu)])\n rows = []\n for x in itertools.product(range(-1, n), repeat=4):\n xa = np.array(x)\n for mu in range(4):\n for nu in range(mu + 1, 4):\n ls = [(xa, mu, 1), (xa + E[mu], nu, 1), (xa + E[nu], mu, -1), (xa, nu, -1)]\n if any(inV(tuple(y)) and not tree(tuple(y), m) for (y, m, sg) in ls):\n rows.append([(var(y, m), sg) for (y, m, sg) in ls])\n cons = []\n for y in itertools.product(range(n // 2), repeat=4):\n for mu in range(4):\n r = {}\n for o in OFFS:\n for k in range(2):\n v = var(2 * np.array(y) + np.array(o) + k * E[mu], mu)\n if v: r[v] = r.get(v, 0) + 1 / 16\n cons.append(list(r.items()))\n def mat(rs, ncol, kind):\n I, J, Dd = [], [], []\n for i, r in enumerate(rs):\n for (v, sg) in r:\n if v and v[0] == kind: I.append(i); J.append(v[1]); Dd.append(sg)\n return sp.csr_matrix((Dd, (I, J)), shape=(len(rs), ncol))\n DV, DE = mat(rows, len(V), \'V\'), mat(rows, len(ext), \'E\')\n BV, BE = mat(cons, len(V), \'V\'), mat(cons, len(ext), \'E\')\n H = (DV.T @ DV).toarray(); B = BV.toarray()\n u, sv, vh = np.linalg.svd(B); N = vh[(sv > 1e-12).sum():].T\n gap = np.linalg.eigvalsh(N.T @ H @ N)[0]\n K = np.block([[H, B.T], [B, np.zeros((B.shape[0],) * 2)]])\n X = np.linalg.solve(K, np.vstack([-(DV.T @ DE).toarray(), -BE.toarray()]))\n return gap, np.abs(X[:len(V)]).sum(axis=0).max(), np.linalg.eigvalsh(B @ B.T)[0], np.linalg.eigvalsh(H)[-1]\nfor n in (2, 4):\n g, Cm, bb, hh = cube(n)\n print(f\' n = {n}: gap {g:.6f}, max ||u_j||_1 {Cm:.4f}, lambda_min(BB^T) {bb:.4f}, ||H|| {hh:.4f}\')\n check(f\'(E) cube n = {n}: gap >= 1/52, BB^T >= 1/16, ||H|| <= 24\', g >= 1 / 52 and bb >= 1 / 16 and hh <= 24)\n\n# (F) invisible class of the line field (face averages, L = 2, corners even)\nSIGMA = {(0,0,0,0):0,(1,0,0,0):0,(0,1,0,0):2,(1,1,0,0):3,(0,0,1,0):3,(1,0,1,0):1,(0,1,1,0):2,(1,1,1,0):1,\n (0,0,0,1):1,(1,0,0,1):2,(0,1,0,1):1,(1,1,0,1):3,(0,0,1,1):3,(1,0,1,1):2,(0,1,1,1):0,(1,1,1,1):0}\nsig = lambda x: SIGMA[tuple(int(c) % 2 for c in x)]\nn = 4\ndef h(x): # indicator of the line through (*,1,1,1)+..., direction 0, transverse coords (1,1,1)\n return 1 if tuple(x[1:]) == (1, 1, 1) else 0\nok_inv, cls = True, set()\nfor y in itertools.product(range(-1, n // 2 + 1), repeat=4):\n for mu in range(4):\n tot = 0\n for o in OFFS:\n if o[mu] != 0: continue\n z = 2 * np.array(y) + np.array(o)\n tot += h(z) - h(z + 2 * E[mu])\n ok_inv &= tot == 0\nfor x in itertools.product(range(2), repeat=4):\n for mu in range(4):\n if sig(x) == mu: continue\n xa = np.array(x)\n if abs(h(xa) - h(xa + E[mu])) == 1: cls.add((x, mu))\ncheck(\'(F) the invisible line changes no face average\', ok_inv)\ncheck(\'(F) exactly twelve classes meet an invisible line once\', len(cls) == 12)\n\nprint(f\'{sum(ok)} checks passed, {len(ok) - sum(ok)} failed\')\nsys.exit(0 if all(ok) else 1)\n', 'blockgap_certificate.py': '"""Independent exact check of the certificate for Proposition prop:blockgapsharp of the forest paper:\nfor every set of blocks W and every phi in Phi_W (Def. def:blockgauge, Thm. thm:blockgap),\n sum_e phi_e^2 <= (1/c) Q(phi), c = 537/5000.\n\nThe certificate (file certificate_c537_5000.json) gives c, multipliers l (4 x 49 rationals) and a symmetric\n245 x 245 matrix G = G_upper/den on the window S(y) = B(y) u B(y+e_0) u ... u B(y+e_3). The program\n\n (a) builds, from the definitions of the paper alone, the translation-invariant symmetric kernels of\n Q(phi) = sum_p (d phi)_p^2, sum_e phi_e^2, sum_{y,mu} V_{y,mu}(phi) L_{y,mu}(phi) and sum_y G(phi|S(y)),\n with L_{y,mu}(phi) = sum_b l[mu][b] phi_{(y,b)}, and checks in exact rational arithmetic that\n Q - c sum phi^2 - sum V L = sum G entry by entry;\n (b) checks that G is positive definite: all leading principal minors of the integer matrix den * G are\n positive (fraction-free Gaussian elimination);\n (c) checks the reduction: on Phi_W every term V_{y,mu} L_{y,mu} vanishes (V = 0 for y in W, and L_{y,mu}\n depends only on links with base in B(y), where phi = 0 for y not in W) on random fields in exact arithmetic.\n\nLocal links of a block: offsets o in {0,1}^4 (itertools.product order) times mu = 0..3, tree links removed; window\nindex = slot * 49 + local index, slots (0, e_0, e_1, e_2, e_3).\n\nUsage: python3 blockgap_certificate.py certificate_c537_5000.json\n"""\n\nimport itertools\nimport json\nimport sys\nfrom fractions import Fraction as Fr\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append((name, bool(ok)))\n print(("PASS " if ok else "FAIL ") + name, flush=True)\n\n\ndef is_tree(o, mu):\n return o[mu] == 0 and all(o[n] == 0 for n in range(mu + 1, 4))\n\n\nLOCAL = [(o, mu) for o in itertools.product((0, 1), repeat=4) for mu in range(4) if not is_tree(o, mu)]\nINDEX = {l: i for i, l in enumerate(LOCAL)}\nNL = len(LOCAL)\nE = [tuple(int(i == mu) for i in range(4)) for mu in range(4)]\nSLOTS = [(0, 0, 0, 0)] + E\n\n\ndef vadd(a, b):\n return tuple(p + q for p, q in zip(a, b))\n\n\ndef vsub(a, b):\n return tuple(p - q for p, q in zip(a, b))\n\n\ndef active(x, mu):\n """(cell, local index) of the link (x, mu), or None for a tree link."""\n cell = tuple(v // 2 for v in x)\n i = INDEX.get((tuple(v % 2 for v in x), mu))\n return None if i is None else (cell, i)\n\n\nclass Kernel:\n """A translation-invariant symmetric bilinear form sum_{y} B(T_y phi), stored by its matrix entries\n K[(delta, a, b)] = coefficient of phi_{(0,a)} phi_{(delta,b)} in the symmetric matrix of the form."""\n\n def __init__(self):\n self.K = {}\n\n def add_local(self, vec_pairs):\n """Add sum_y of the rank-one or general local form sum_{i,j} w_ij phi_{(c_i,a_i)} phi_{(c_j,a_j)};\n vec_pairs: list of ((c_i,a_i), (c_j,a_j), w_ij) over ordered pairs (the symmetric matrix of a local form)."""\n for (c1, a), (c2, b), w in vec_pairs:\n k = (vsub(c2, c1), a, b)\n self.K[k] = self.K.get(k, 0) + w\n\n\ndef rank_one(v):\n return [(l1, l2, s1 * s2) for l1, s1 in v for l2, s2 in v]\n\n\ndef sym_product(u, v):\n out = []\n for l1, s1 in u:\n for l2, s2 in v:\n out.append((l1, l2, Fr(s1 * s2, 2) if isinstance(s1 * s2, int) else s1 * s2 / 2))\n out.append((l2, l1, Fr(s1 * s2, 2) if isinstance(s1 * s2, int) else s1 * s2 / 2))\n return out\n\n\ndef main(path):\n cert = json.load(open(path))\n c = Fr(cert["c"])\n lmul = [[Fr(x) for x in cert["L"][mu * NL:(mu + 1) * NL]] for mu in range(4)]\n den = int(cert["den"])\n NW = 5 * NL\n Gint = [[0] * NW for _ in range(NW)]\n for i, row in enumerate(cert["G_upper"]):\n for k, v in enumerate(row):\n Gint[i][i + k] = Gint[i + k][i] = int(v)\n check(f"certificate: c = {c}, {NL} active links per block, window of {NW} links, "\n f"{len(cert[\'L\'])} multipliers", NL == 49 and len(cert["L"]) == 4 * NL and len(cert["G_upper"]) == NW)\n\n # Q: every plaquette, counted once per translation class of blocks, as the plaquettes with base in B(0)\n KQ = Kernel()\n for o in itertools.product((0, 1), repeat=4):\n for mu, nu in itertools.combinations(range(4), 2):\n x = o\n sides = [(x, mu, 1), (vadd(x, E[mu]), nu, 1), (vadd(x, E[nu]), mu, -1), (x, nu, -1)]\n v = [(active(s, d), sg) for s, d, sg in sides if active(s, d) is not None]\n KQ.add_local(rank_one(v))\n KS = Kernel()\n KS.add_local([((SLOTS[0], a), (SLOTS[0], a), 1) for a in range(NL)])\n # sum_mu V_{0,mu} L_{0,mu}, translated\n KV = Kernel()\n for mu in range(4):\n vrow = {}\n for o in itertools.product((0, 1), repeat=4):\n for s in (o, vadd(o, E[mu])):\n l = active(s, mu)\n if l is not None:\n vrow[l] = vrow.get(l, 0) + Fr(1, 16)\n lrow = [((SLOTS[0], b), lmul[mu][b]) for b in range(NL) if lmul[mu][b] != 0]\n KV.add_local(sym_product(list(vrow.items()), lrow))\n KG = Kernel()\n win = [(SLOTS[s], a) for s in range(5) for a in range(NL)]\n KG.add_local([(win[i], win[j], Fr(Gint[i][j], den)) for i in range(NW) for j in range(NW) if Gint[i][j]])\n\n keys = set(KQ.K) | set(KS.K) | set(KV.K) | set(KG.K)\n bad = [k for k in keys if KQ.K.get(k, 0) - c * KS.K.get(k, 0) - KV.K.get(k, 0) != KG.K.get(k, 0)]\n check(f"(a) Q - c sum phi^2 - sum V L = sum G as translation-invariant kernels, exactly, "\n f"on all {len(keys)} entries (failing: {len(bad)})", not bad)\n\n # (b) positive definiteness by fraction-free elimination\n A = [row[:] for row in Gint]\n prev, ok = 1, True\n for k in range(NW):\n if A[k][k] <= 0:\n ok = False\n break\n for i in range(k + 1, NW):\n for j in range(k + 1, NW):\n A[i][j] = (A[i][j] * A[k][k] - A[i][k] * A[k][j]) // prev\n prev = A[k][k]\n check(f"(b) all {NW} leading principal minors of den * G are positive", ok)\n\n # (c) the multiplier terms vanish on Phi_W (W = a 2 x 1 x 1 x 1 row of blocks), exactly\n import random\n rnd = random.Random(5)\n W = [(0, 0, 0, 0), (1, 0, 0, 0)]\n var = [(cell, a) for cell in W for a in range(NL)]\n vrows = []\n for y in W:\n for mu in range(4):\n r = {}\n for o in itertools.product((0, 1), repeat=4):\n x = tuple(2 * y[i] + o[i] for i in range(4))\n for s in (x, vadd(x, E[mu])):\n l = active(s, mu)\n if l is not None and l[0] in W:\n r[l] = r.get(l, 0) + Fr(1, 16)\n vrows.append(r)\n # exact projection of a random rational field onto {V_{y,mu} = 0, y in W} (Gaussian elimination)\n phi = {v: Fr(rnd.randint(-9, 9), rnd.randint(1, 9)) for v in var}\n rows = [dict(r) for r in vrows]\n piv = []\n for r in rows:\n for v, p in piv:\n if v in r and r[v] != 0:\n f = r[v] / p[v]\n for u, w in p.items():\n r[u] = r.get(u, 0) - f * w\n nz = [v for v in r if r[v] != 0]\n if nz:\n piv.append((nz[0], r))\n for v, p in reversed(piv):\n # set phi[v] so that p(phi) = 0\n s = sum(w * phi[u] for u, w in p.items() if u != v)\n phi[v] = -s / p[v]\n for v, p in piv:\n s = sum(w * phi[u] for u, w in p.items())\n assert s == 0\n allzero = True\n for y in itertools.product(range(-1, 3), (-1, 0, 1), (-1, 0, 1), (-1, 0, 1)):\n for mu in range(4):\n V = Fr(0)\n for o in itertools.product((0, 1), repeat=4):\n x = tuple(2 * y[i] + o[i] for i in range(4))\n for s in (x, vadd(x, E[mu])):\n l = active(s, mu)\n if l is not None:\n V += Fr(1, 16) * phi.get(l, 0)\n Lv = sum(lmul[mu][b] * phi.get((y, b), 0) for b in range(NL))\n if V * Lv != 0:\n allzero = False\n check("(c) on a field of Phi_W (two blocks) every term V_{y,mu} L_{y,mu} vanishes, exactly", allzero)\n print(f"{sum(ok for _, ok in checks)} of {len(checks)} checks passed")\n\n\nif __name__ == "__main__":\n main(sys.argv[1])\n', 'box_extension.py': '"""Checks of the box extension lemma and the conditional density bound\n(Lemma lem:boxextension and Proposition prop:conddensity of the forest\npaper, Sec. ssec:largefields).\n\nFor boxes [0,l]^4 with l = 2, 3, 4 and random closed boundary data with\nplaquette angles at most rho_s on the boundary sphere, this program\n\n (a) builds the real lift alpha on the boundary facet by facet in the\n order f1+, f2+, f2-, f3+, f3-, f4+, f4-, f1-, with the axial gauge on\n each facet and the McShane extension of the potential of the\n difference, and checks d alpha = theta, the agreement on earlier\n facets, and |alpha| <= 13118 l rho_s;\n (b) checks that the path metric of the union Gamma of earlier facets is\n at most three times the l^1 metric of the facet;\n (c) recovers the given torus links from alpha up to a gauge;\n (d) evaluates the radial Whitney extension by quadrature and checks that\n it reproduces alpha on the boundary links and that every plaquette of\n the box has angle at most C rho_s, C = sqrt(3)(24*13118+9);\n (e) checks the constants: the recursion M_8 = 13118, C, the Haar bound\n of a ball in SU(2), and the exponent of the density bound.\n\nUsage: python3 box_extension.py\n"""\n\nimport itertools\nimport math\nimport random\nfrom collections import deque\n\nimport numpy as np\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append((name, bool(ok)))\n print(("ok " if ok else "FAIL ") + name)\n\n\ndef unit(m):\n v = [0, 0, 0, 0]\n v[m] = 1\n return tuple(v)\n\n\ndef add(x, y):\n return tuple(a + b for a, b in zip(x, y))\n\n\ndef box(l):\n verts = list(itertools.product(range(l + 1), repeat=4))\n links = [(x, m) for x in verts for m in range(4) if x[m] < l]\n plaqs = [(x, m, n) for x in verts for m in range(4) for n in range(m + 1, 4)\n if x[m] < l and x[n] < l]\n return verts, links, plaqs\n\n\ndef on_bdry(x, l):\n return any(c in (0, l) for c in x)\n\n\ndef link_in_face(e, i, s, l):\n x, m = e\n return m != i and x[i] == s * l\n\n\ndef plaq_in_face(p, i, s, l):\n x, m, n = p\n return m != i and n != i and x[i] == s * l\n\n\ndef bdry_link(e, l):\n x, m = e\n return any(x[k] in (0, l) for k in range(4) if k != m)\n\n\ndef bdry_plaq(p, l):\n x, m, n = p\n return any(x[k] in (0, l) for k in range(4) if k not in (m, n))\n\n\ndef plaq_links(p):\n x, m, n = p\n return [((x, m), 1), ((add(x, unit(m)), n), 1),\n ((add(x, unit(n)), m), -1), ((x, n), -1)]\n\n\ndef curl(a, p):\n return sum(s * a[e] for e, s in plaq_links(p))\n\n\ndef wrap(t):\n return (t + math.pi) % (2 * math.pi) - math.pi\n\n\nORDER = [(0, 1), (1, 1), (1, 0), (2, 1), (2, 0), (3, 1), (3, 0), (0, 0)]\n\n\ndef axial(l, i, s, theta):\n d1, d2, d3 = [k for k in range(4) if k != i]\n a = {}\n face = [x for x in itertools.product(range(l + 1), repeat=4) if x[i] == s * l]\n for x in face:\n if x[d3] < l:\n a[(x, d3)] = 0.0\n for x in sorted(face, key=lambda y: y[d3]):\n if x[d2] < l:\n if x[d3] == 0:\n a[(x, d2)] = 0.0\n if x[d3] < l:\n a[(add(x, unit(d3)), d2)] = a[(x, d2)] - theta[(x, d2, d3)]\n for x in sorted(face, key=lambda y: (y[d3], y[d2])):\n if x[d1] < l:\n if x[d2] == 0 and x[d3] == 0:\n a[(x, d1)] = 0.0\n if x[d3] == 0 and x[d2] < l:\n a[(add(x, unit(d2)), d1)] = a[(x, d1)] - theta[(x, d1, d2)]\n if x[d3] < l:\n a[(add(x, unit(d3)), d1)] = a[(x, d1)] - theta[(x, d1, d3)]\n return a\n\n\ndef lift(l, theta):\n """Facet-by-facet lift; returns alpha and the list of M_k/(l rho)."""\n rho = max(abs(theta[p]) for p in theta)\n alpha = {}\n Ms = []\n gamma_ratio = 0.0\n for k, (i, s) in enumerate(ORDER):\n a0 = axial(l, i, s, theta)\n flinks = list(a0)\n fpl = [p for p in theta if plaq_in_face(p, i, s, l)]\n assert all(abs(curl(a0, p) - theta[p]) < 1e-12 for p in fpl)\n assert max(abs(v) for v in a0.values()) <= 2 * l * rho + 1e-12\n gl = [e for e in flinks if e in alpha]\n if not gl:\n for e in flinks:\n alpha[e] = a0[e]\n else:\n om = {e: alpha[e] - a0[e] for e in gl}\n adj = {}\n for (x, m) in gl:\n y = add(x, unit(m))\n adj.setdefault(x, []).append((y, om[(x, m)]))\n adj.setdefault(y, []).append((x, -om[(x, m)]))\n gv = list(adj)\n lam = {gv[0]: 0.0}\n dq = deque([gv[0]])\n while dq:\n x = dq.popleft()\n for y, w in adj[x]:\n if y not in lam:\n lam[y] = lam[x] + w\n dq.append(y)\n else:\n assert abs(lam[y] - lam[x] - w) < 1e-9, "omega not exact"\n assert len(lam) == len(gv)\n L = 3 * max(abs(v) for v in om.values())\n # path metric of Gamma against the l^1 metric\n for x in gv:\n dist = {x: 0}\n dq = deque([x])\n while dq:\n u = dq.popleft()\n for v, _ in adj[u]:\n if v not in dist:\n dist[v] = dist[u] + 1\n dq.append(v)\n for v, dv in dist.items():\n d1 = sum(abs(a - b) for a, b in zip(x, v))\n if d1:\n gamma_ratio = max(gamma_ratio, dv / d1)\n fverts = {x for (x, m) in flinks} | {add(x, unit(m)) for (x, m) in flinks}\n lt = {x: min(lam[y] + L * sum(abs(a - b) for a, b in zip(x, y)) for y in gv)\n for x in fverts}\n for (x, m) in flinks:\n val = a0[(x, m)] + lt[add(x, unit(m))] - lt[x]\n if (x, m) in alpha:\n assert abs(val - alpha[(x, m)]) < 1e-9\n else:\n alpha[(x, m)] = val\n Ms.append(max(abs(v) for v in alpha.values()) / (l * rho))\n return alpha, Ms, gamma_ratio\n\n\ndef whitney_extension(l, alpha, npts=12, nsub=24):\n """B_e = integral over e of (r/R0)^2 phi^* hat(alpha)."""\n c = np.full(4, l / 2.0)\n R0 = l / 2.0\n gx, gw = np.polynomial.legendre.leggauss(npts)\n ts, ws = [], []\n for j in range(nsub):\n ts.extend((j + (gx + 1) / 2) / nsub)\n ws.extend(gw / (2 * nsub))\n ts, ws = np.array(ts), np.array(ws)\n\n def form(y, i, s, v):\n """hat(alpha) at the point y of facet (i, s) applied to v."""\n dirs = [k for k in range(4) if k != i]\n u = np.array([y[k] for k in dirs])\n q = np.minimum(np.floor(u), l - 1).astype(int)\n f = u - q\n tot = 0.0\n for a, k in enumerate(dirs):\n others = [b for b in range(3) if b != a]\n val = 0.0\n for e0, e1 in itertools.product((0, 1), repeat=2):\n corner = q.copy()\n corner[others[0]] += e0\n corner[others[1]] += e1\n w = ((f[others[0]] if e0 else 1 - f[others[0]])\n * (f[others[1]] if e1 else 1 - f[others[1]]))\n x = [0, 0, 0, 0]\n x[i] = s * l\n for b, kk in enumerate(dirs):\n x[kk] = int(corner[b])\n val += w * alpha[(tuple(x), k)]\n tot += val * v[k]\n return tot\n\n B = {}\n for (x, m) in alpha_links(l):\n tot = 0.0\n for t, w in zip(ts, ws):\n p = np.array(x, dtype=float)\n p[m] += t\n z = p - c\n r = np.max(np.abs(z))\n if r < 1e-14:\n continue\n i = int(np.argmax(np.abs(z)))\n s = 1 if z[i] > 0 else 0\n phi = c + R0 * z / r\n phi[i] = s * l\n v = np.zeros(4)\n v[m] = 1.0\n grad = np.zeros(4)\n grad[i] = 1.0 if s else -1.0\n dphi = (R0 / r) * (v - z * (grad @ v) / r)\n tot += w * (r / R0) ** 2 * form(phi, i, s, dphi)\n B[(x, m)] = tot\n return B\n\n\ndef alpha_links(l):\n return box(l)[1]\n\n\ndef run(l, seed, ext=True):\n rng = random.Random(seed)\n verts, links, plaqs = box(l)\n bl = [e for e in links if bdry_link(e, l)]\n bp = [p for p in plaqs if bdry_plaq(p, l)]\n # torus data: a small curvature part, a large gauge part, reduced mod 2 pi\n small = {e: rng.uniform(-1, 1) for e in bl}\n mu = {x: rng.uniform(-math.pi, math.pi) for x in verts if on_bdry(x, l)}\n raw = {e: small[e] for e in bl}\n th0 = {p: curl(raw, p) for p in bp}\n rho_s = 0.3\n sc = rho_s / max(abs(v) for v in th0.values())\n given = {(x, m): wrap(sc * small[(x, m)] + mu[add(x, unit(m))] - mu[x])\n for (x, m) in bl}\n theta = {p: wrap(curl(given, p)) for p in bp}\n rho = max(abs(v) for v in theta.values())\n check(f"l={l} seed={seed}: boundary angles at most rho_s < pi/3",\n rho <= rho_s + 1e-12 and rho_s < math.pi / 3)\n alpha, Ms, gr = lift(l, theta)\n check(f"l={l} seed={seed}: d alpha = theta on every boundary plaquette",\n max(abs(curl(alpha, p) - theta[p]) for p in bp) < 1e-9)\n bound = [2]\n for _ in range(7):\n bound.append(3 * bound[-1] + 8)\n check(f"l={l} seed={seed}: M_k/(l rho) {[round(v, 2) for v in Ms]} within "\n f"{bound}", all(a <= b + 1e-9 for a, b in zip(Ms, bound)))\n check(f"l={l} seed={seed}: path metric of Gamma at most {gr:.3f} <= 3 "\n f"times the l^1 metric", gr <= 3 + 1e-12)\n # gauge: given - alpha is d mu mod 2 pi on the boundary\n gam = {e: wrap(given[e] - alpha[e]) for e in bl}\n check(f"l={l} seed={seed}: given - alpha is flat mod 2 pi",\n max(abs(wrap(curl(gam, p))) for p in bp) < 1e-9)\n if not ext:\n return\n B = whitney_extension(l, alpha)\n check(f"l={l} seed={seed}: extension reproduces alpha on boundary links",\n max(abs(B[e] - alpha[e]) for e in bl) < 1e-9)\n C = math.sqrt(3) * (24 * 13118 + 9)\n m = max(abs(curl(B, p)) for p in plaqs)\n check(f"l={l} seed={seed}: largest box plaquette angle {m / rho:.2f} rho_s "\n f"<= C rho_s, C = {C:.0f}", m <= C * rho)\n\n\nprint("(a)-(d) lift and extension")\nfor l in (2, 3, 4):\n for seed in range(3):\n run(l, seed, ext=(l <= 3 or seed == 0))\n\nprint("(e) constants")\nM = 2\nfor _ in range(7):\n M = 3 * M + 8\ncheck(f"M_8 = {M} = 13118", M == 13118)\nC = math.sqrt(3) * (24 * 13118 + 9)\ncheck(f"C = sqrt(3)(24*13118+9) = {C:.1f} < 545400", C < 545400)\n# Haar measure of the ball of angle t in SU(2): (2/pi) int_0^t sin^2\nfor t in np.linspace(1e-3, math.pi / 2, 200):\n v = (t - math.sin(t) * math.cos(t)) / math.pi\n assert v >= 8 * t ** 3 / (3 * math.pi ** 3) - 1e-15\ncheck("Haar ball of angle t <= pi/2 has measure >= 8 t^3/(3 pi^3)", True)\nC0 = 0.5 + 2 / 3 * math.log(24 * math.pi ** 3)\nfor l in range(2, 40):\n nP = 6 * l * l * (l + 1) ** 2\n nL = 4 * l * (l + 1) ** 3\n assert nP <= 6 * (l + 1) ** 4 and nL <= 4 * (l + 1) ** 4\n # n_P + n_L log(24 pi^3 beta^{3/2}) <= 6(l+1)^4 (log beta + C0 + 1/2)\n for beta in (1.0, 10.0, 1e3, 1e8):\n lhs = nP + nL * math.log(24 * math.pi ** 3 * beta ** 1.5)\n rhs = 6 * (l + 1) ** 4 * (math.log(beta) + C0 + 0.5)\n assert lhs <= rhs + 1e-9\ncheck("counts of plaquettes and links and the exponent of the bound", True)\n\nnpass = sum(ok for _, ok in checks)\nprint(f"{npass} checks passed, {len(checks) - npass} failed")\n', 'calm_fibre.py': '"""Checks of the density bound for one cut-off average (lemma averagedensity)\nand of the Peierls bound on a calm fibre (proposition calmfibre), for SU(2).\n\nPaths of one coarse link: P = l_0 = g, P_x = u_a l_a, P_x\' = l_a w_a. In the\nregion R_1 (maximum at a site x_a) the coordinates are h_a = g^{-1} u_a l_a,\nand v_x\' = g^{-1} u_a^{-1} g h_a w_a. The script\n(A) checks the constants: M = 1 + 2(1 - 7 Lambda/8)^{-3} < 2.4e4,\n 1 + 7 Lambda/8 < 1.957, (7 Lambda/8) 46 < 44, (M^4 1.957^12)^{1/45} < 2.93,\n 14 188^3 < 9.31e7, and h(B_rho) = (2 theta - sin 2 theta)/(2 pi) >= rho^3/14\n for rho <= 0.1, theta = rho/sqrt 2, together with the Monte Carlo value of\n the Haar measure of a small ball;\n(B) on random points of R_1 and R_2: the determinant of the derivative of\n g -> V(g, h) is at least (1 - 7 Lambda/8)^3, and the fixed point iteration\n g -> c exp(-chi N(g)) started at many points of S_h returns to the same g;\n(C) on calm backgrounds: the iteration l -> c exp(-N(l)) with perturbed inner\n and private links stays in the ball of radius 44 rho about the path link,\n converges, and |det dV/dl_0| <= 1.957^3.\nDouble precision; the proofs in the paper are by hand.\nUsage: python3 calm_fibre.py\n"""\nimport numpy as np\nfrom scipy.linalg import expm, logm\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append(bool(ok))\n print(("PASS " if ok else "FAIL ") + name)\n\n\nS = [np.array(m, complex) for m in ([[0, 1], [-1, 0]], [[0, 1j], [1j, 0]], [[1j, 0], [0, -1j]])]\nB = [s / np.sqrt(2) for s in S] # orthonormal for Re tr(X^* Y)\n\n\ndef alg(c):\n return sum(ci * b for ci, b in zip(c, B))\n\n\ndef coords(X):\n return np.array([np.real(np.trace(b.conj().T @ X)) for b in B])\n\n\ndef haar(rng):\n q = rng.normal(size=4); q /= np.linalg.norm(q)\n return np.array([[q[0] + 1j * q[1], q[2] + 1j * q[3]], [-q[2] + 1j * q[3], q[0] - 1j * q[1]]])\n\n\ndef lg(g):\n X = logm(g)\n return (X - X.conj().T) / 2\n\n\ndef dist(a, b):\n return np.linalg.norm(lg(a.conj().T @ b))\n\n\ndef delta(v):\n return np.linalg.norm(v - np.eye(2))\n\n\ndef phi(t):\n return min(1.0, max(0.0, 2 - 2 * t))\n\n\nALPHA = 2 * np.arcsin(1 / (2 * np.sqrt(2)))\nLAM = ALPHA / np.sin(ALPHA)\nK7 = 7 * LAM / 8\nMARGIN = 1 - K7\nM = 1 + 2 * MARGIN ** -3\ncheck(f"M = 1 + 2(1 - 7 Lambda/8)^-3 = {M:.1f} < 2.4e4", M < 2.4e4)\ncheck(f"1 + 7 Lambda/8 = {1 + K7:.6f} < 1.957", 1 + K7 < 1.957)\ncheck(f"(7 Lambda/8) 46 = {46 * K7:.3f} < 44", 46 * K7 < 44)\ncheck(f"(M^4 1.957^12)^(1/45) = {(M ** 4 * 1.957 ** 12) ** (1 / 45):.4f} < 2.93",\n (M ** 4 * 1.957 ** 12) ** (1 / 45) < 2.93)\ncheck(f"14 188^3 = {14 * 188 ** 3} < 9.31e7", 14 * 188 ** 3 < 9.31e7)\nrhos = np.linspace(1e-6, 0.1, 100001)\nth = rhos / np.sqrt(2)\ncheck("h(B_rho) >= rho^3/14 for rho <= 0.1",\n np.all((2 * th - np.sin(2 * th)) / (2 * np.pi) >= rhos ** 3 / 14))\nrng = np.random.default_rng(7)\nq = rng.normal(size=(2_000_000, 4)); q /= np.linalg.norm(q, axis=1)[:, None]\nr0 = 0.6\nt0 = r0 / np.sqrt(2)\n# the ball of radius r0 about I: angle arccos(q_0) <= t0 (q_0 > 0 side only)\nfrac = np.mean(np.arccos(np.clip(q[:, 0], -1, 1)) <= t0)\ncheck(f"Haar measure of the ball of radius 0.6: Monte Carlo {frac:.5f}, "\n f"formula {(2 * t0 - np.sin(2 * t0)) / (2 * np.pi):.5f}",\n abs(frac - (2 * t0 - np.sin(2 * t0)) / (2 * np.pi)) < 5e-4)\n\n\ndef near(rng, s):\n return expm(alg(rng.normal(size=3) * s / np.sqrt(3)))\n\n\ndef V_region(g, h, u, w, kind):\n """cut-off average in the coordinates of R_1 (kind 1) or R_2 (kind 2)."""\n vs = []\n for a in range(7):\n if kind == 1:\n vs += [h[a], g.conj().T @ u[a].conj().T @ g @ h[a] @ w[a]]\n else:\n vs += [g.conj().T @ u[a] @ g @ h[a] @ w[a].conj().T, h[a]]\n m = max(delta(v) for v in vs)\n mh = max(delta(v) for v in h)\n N = sum(lg(v) for v in vs) / 16\n return g @ expm(phi(mh) * N), m, mh, N\n\n\ndef in_S(g, h, u, w, kind):\n _, m, mh, _ = V_region(g, h, u, w, kind)\n return mh < 1 and m <= mh + 1e-12\n\n\nleast_det, ok_unique, tested, solved = 9.0, True, 0, 0\nfor kind in (1, 2):\n for t in range(60):\n g = haar(rng)\n sc = rng.uniform(0.1, 0.6)\n h = [near(rng, sc) for _ in range(7)]\n mh = max(delta(v) for v in h)\n u = [haar(rng) for _ in range(7)]\n # choose the fixed links w_a so that the other seven sites are inside the ball of radius m_h\n w = []\n for a in range(7):\n s_a = near(rng, rng.uniform(0, 0.9) * mh / 1.5)\n if kind == 1:\n w.append(np.linalg.inv(g.conj().T @ u[a].conj().T @ g @ h[a]) @ s_a)\n else:\n w.append((np.linalg.inv(g.conj().T @ u[a] @ g @ h[a]) @ s_a).conj().T)\n if not in_S(g, h, u, w, kind):\n continue\n tested += 1\n V0 = V_region(g, h, u, w, kind)[0]\n cols = []\n for k in range(3):\n e = 1e-6\n Vp = V_region(expm(e * B[k]) @ g, h, u, w, kind)[0]\n Vm = V_region(expm(-e * B[k]) @ g, h, u, w, kind)[0]\n cols.append(coords(lg(Vp @ V0.conj().T) - lg(Vm @ V0.conj().T)) / (2 * e))\n least_det = min(least_det, abs(np.linalg.det(np.array(cols).T)))\n c = V0\n for start in range(4):\n x = g @ near(rng, rng.uniform(0.05, 0.5))\n if not in_S(x, h, u, w, kind):\n continue\n for it in range(300):\n _, _, mh2, N = V_region(x, h, u, w, kind)\n x = c @ expm(-phi(mh2) * N)\n if in_S(x, h, u, w, kind) and np.linalg.norm(V_region(x, h, u, w, kind)[0] - c) < 1e-9:\n solved += 1\n ok_unique &= dist(x, g) < 1e-7\nprint(f"regions R_1, R_2: {tested} sampled points, least |det| {least_det:.4f}, {solved} solutions found from other starts")\ncheck(f"|det dV/dg| >= (1 - 7 Lambda/8)^3 = {MARGIN ** 3:.2e} on R_1 and R_2",\n tested > 50 and least_det >= MARGIN ** 3)\ncheck("every solution of V(g, h) = c in S_h found by the iteration is the sampled g", ok_unique and solved > 20)\n\nworst_ratio, max_det, conv = 0.0, 0.0, True\nfor t in range(200):\n kap = 10 ** rng.uniform(-6, -3)\n l0 = haar(rng)\n u = [near(rng, kap) for _ in range(7)]\n w = [near(rng, kap) for _ in range(7)]\n l = [l0 @ near(rng, 10 * kap) for _ in range(7)]\n\n def Nk(x0, u, l, w):\n vs = []\n for a in range(7):\n vs += [x0.conj().T @ u[a] @ l[a], x0.conj().T @ l[a] @ w[a]]\n return sum(lg(v) for v in vs) / 16\n\n c = l0 @ expm(Nk(l0, u, l, w))\n rho = 10 ** rng.uniform(-6, -3)\n def pert(g):\n z = rng.normal(size=3)\n return g @ expm(alg(z / np.linalg.norm(z)) * rho * rng.uniform())\n u2, l2, w2 = [pert(x) for x in u], [pert(x) for x in l], [pert(x) for x in w]\n x = l0\n for it in range(200):\n x = c @ expm(-Nk(x, u2, l2, w2))\n worst_ratio = max(worst_ratio, dist(x, l0) / rho)\n V = x @ expm(Nk(x, u2, l2, w2))\n conv &= np.linalg.norm(V - c) < 1e-10\n cols = []\n for k in range(3):\n e = 1e-7\n Vp = expm(e * B[k]) @ x @ expm(Nk(expm(e * B[k]) @ x, u2, l2, w2))\n Vm = expm(-e * B[k]) @ x @ expm(Nk(expm(-e * B[k]) @ x, u2, l2, w2))\n cols.append(coords(lg(Vp @ V.conj().T) - lg(Vm @ V.conj().T)) / (2 * e))\n max_det = max(max_det, abs(np.linalg.det(np.array(cols).T)))\nprint(f"calm backgrounds: largest d(l, l_0)/rho along the iteration {worst_ratio:.3f}, "\n f"largest |det| {max_det:.4f}")\ncheck("the iteration stays within 44 rho of the path link and solves the constraint",\n conv and worst_ratio <= 44)\ncheck(f"|det dV/dl_0| <= 1.957^3 = {1.957 ** 3:.3f} on calm backgrounds", max_det <= 1.957 ** 3)\nprint(f"{sum(checks)} of {len(checks)} checks passed")\n', 'calm_windows.py': '"""Checks of the windows with a calm completion (corollary localcalm) and of\nthe obstruction on cubes of fixed physical size (proposition calmrare).\n\n(A) enumerates, for every unit cube x + [0,1]^4, the blocks y whose\n neighbourhood {y}^+ contains a block holding a vertex of the cube, and\n confirms that there are at most 256; checks 16 * 256 = 4096 and\n rho = K/(3072 m) <= K/(8 n_P) for n_P <= 384 m;\n(B) checks the constants of proposition calmrare: the integral of\n e^{-s^2} s^2 over [0, pi sqrt3/2] exceeds 0.44, the ratio 9.72, the\n factor (pi/(2 sqrt2))^3 < 1.371, the bound 7e-32, the logarithm 162.8\n and the threshold 10^24, the last four in exact rational arithmetic\n where they are rational;\n(C) computes the probability of the cap {angle <= theta} under the density\n proportional to e^{6 beta cos t} sin^2 t by quadrature for beta from 1\n to 10^6 and rho\' from 10^-4 to 1, and compares it with\n 14 (beta rho\'^2)^{3/2}.\nDouble precision in (B) and (C) where not stated; the proofs in the paper\nare by hand.\nUsage: python3 calm_windows.py\n"""\nfrom fractions import Fraction as Fr\nfrom itertools import product\nfrom math import pi, sqrt, cos, sin, exp, log, floor\nimport numpy as np\nfrom scipy.integrate import quad\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append(bool(ok))\n print(("PASS " if ok else "FAIL ") + name)\n\n\n# (A)\nworst = 0\nfor x in product(range(4), repeat=4):\n blocks = set()\n for v in product(*[(xi, xi + 1) for xi in x]):\n yp = tuple(vi // 2 for vi in v)\n for d in product((-1, 0, 1), repeat=4):\n blocks.add(tuple(a + b for a, b in zip(yp, d)))\n worst = max(worst, len(blocks))\ncheck(f"at most 256 blocks y per unit cube (found {worst})", worst <= 256)\ncheck("16 * 256 = 4096", 16 * 256 == 4096)\ncheck("K/(3072 m) <= K/(8 * 384 m)", Fr(1, 3072) <= Fr(1, 8 * 384))\n\n# (B)\nI044 = quad(lambda s: exp(-s * s) * s * s, 0, pi * sqrt(3) / 2)[0]\ncheck(f"int_0^(pi sqrt3/2) e^-s^2 s^2 ds = {I044:.5f} > 0.44", I044 > 0.44)\nratio = pi**2 * 3**1.5 / (3 * 4 * 0.44)\ncheck(f"ratio pi^2 3^(3/2)/(3*4*0.44) = {ratio:.4f} <= 9.72", ratio <= 9.72)\nfac = (pi / (2 * sqrt(2)))**3\ncheck(f"(pi/(2 sqrt2))^3 = {fac:.4f} < 1.371", fac < 1.371)\ncheck("9.72 * 1.371 < 14", Fr(972, 100) * Fr(1371, 1000) < 14)\ncheck("n_P >= 294/4 |W| = 73.5 |W|", Fr(49 * 6, 4) == Fr(735, 10))\ncheck("14e-24/(512 * 73.5^3) < 7e-32",\n Fr(14, 10**24) / (512 * Fr(735, 10)**3) < Fr(7, 10**32))\ncheck("8 * 4096 * 1.05e7 < 3.45e11", 8 * 4096 * Fr(105, 10) * 10**6\n < Fr(345, 100) * 10**11)\ncheck("3.45e11 >= 1.05e7 * 32^3", Fr(345, 100) * 10**11\n >= Fr(105, 10) * 10**6 * 32**3)\nLg = log(1.05e7 * 32**3) + 6 * log(73.5) + 48 * log(10)\ncheck(f"ln(1.05e7 * 32^3 * 73.5^6 / 1e-48) = {Lg:.3f} > 162.8", Lg > 162.8)\ncheck("512*49*73.5*162.8*1e16/3 > 1e24",\n 512 * 49 * Fr(735, 10) * Fr(1628, 10) * 10**16 / 3 > 10**24)\n\n# (C)\nokc = True\nworstr = 0.0\nfor beta in [1, 2, 5, 10, 100, 1e3, 1e4, 1e6]:\n def f(t):\n return exp(6 * beta * (cos(t) - 1)) * sin(t)**2\n brk = min(pi, 8 / sqrt(beta))\n den = quad(f, 0, brk, limit=200)[0] + quad(f, brk, pi, limit=200)[0]\n for rp in [1e-4, 1e-3, 1e-2, 0.1, 0.3, 1.0]:\n th = 2 * np.arcsin(rp / (2 * sqrt(2)))\n num = quad(f, 0, min(th, pi), limit=200)[0]\n p = num / den\n b = 14 * (beta * rp * rp)**1.5\n okc &= p <= b\n if b > 0:\n worstr = max(worstr, p / b)\ncheck(f"cap probability <= 14 (beta rho\'^2)^(3/2) (largest ratio "\n f"{worstr:.3f})", okc)\n\nprint(f"{sum(checks)} of {len(checks)} checks passed")\n', 'chart_decay.py': '"""Checks of the product chart and of the decay of the chart Hessian\n(Theorem thm:chartdecay of the forest paper, Sec. ssec:smallfibres), for\nG = SU(2) on the periodic lattice of side 12, with W a row of five blocks.\n\nFor every constraint k = (y, mu) the path link d_k = (2y + e_mu, mu) enters\nV_{y,mu} with weight 1/8 and no other average. The section S writes an\nelement of T = ker B through its coordinates xi on the other links: the\ncoordinate at d_k solves the constraint k. The program\n\n (k) checks that d_k enters only the constraint k, that B S = 0, that S is\n injective with image T, records max_k |B_{k,d_k}^{-1}| and the largest\n l^infinity block row sum of S at the path links, which the proof\n bounds by 8.01 and 15.1 for kappa <= 1e-8;\n (l) checks that Pbar = P S, P = 1 - B^*(A B^*)^{-1} A, has Pbar^* Pbar >= 1\n at points of the chart;\n (m) records, against the l^infinity distance between link midpoints, the\n largest block norms of G^{-1} = (B B^*)^{-1}, and of Pbar at a point of\n the chart, and checks that they decay (at the base point Pbar = S has\n finite range, since there A = B and P S = S);\n (n) computes, by second differences of Q(U exp(X(xi))) with X(xi) =\n S xi + h(S xi), blocks of the Hessian in xi at that point for pairs\n of links at increasing distance, and checks that their norms decay;\n (o) checks the arithmetic of the constants of the proof exactly.\n\nThese are floating-point checks at fields far larger than those of the\ntheorem; they are not interval certificates.\n\nUsage: python3 chart_decay.py\n"""\n\nimport itertools\nfrom fractions import Fraction as Fr\n\nimport numpy as np\n\nimport small_field_fibre as S\n\n# a larger lattice, so that distances up to nine occur inside W\nS.L = 12\nS.SITES = list(itertools.product(range(S.L), repeat=S.DIM))\nS.BLOCKS = list(itertools.product(range(S.L // 2), repeat=S.DIM))\nS.PLAQ = [(x, mu, nu) for x in S.SITES for mu in range(S.DIM) for nu in range(mu + 1, S.DIM)]\n\nimport fibre_chart as FC # noqa: E402\n\nchecks = FC.checks\ncheck = FC.check\n\n\ndef mid(l):\n x, mu = l\n return np.array(x, float) + 0.5 * np.eye(S.DIM)[mu]\n\n\ndef dist(l1, l2):\n return float(np.max(np.abs(mid(l1) - mid(l2))))\n\n\ndef blocknorm(M, i, j):\n return np.linalg.norm(M[3 * i:3 * i + 3, 3 * j:3 * j + 3], 2)\n\n\ndef envelope(pairs):\n """pairs of (distance, norm) -> sorted list of (d, max norm at distance >= d)."""\n ds = sorted({round(d, 6) for d, _ in pairs})\n return [(d, max(v for dd, v in pairs if dd >= d - 1e-9)) for d in ds]\n\n\ndef run(eps, seed, s):\n W = [(j, 0, 0, 0) for j in range(5)]\n st = FC.setup(eps, W, seed)\n kappa = st["kappa"]\n tag = f"eps={eps:g}, |W|={len(W)}, kappa={kappa:.3e}"\n print(f"-- row of five blocks: {tag}")\n var, vid, cons, n = st["var"], st["vid"], st["cons"], st["n"]\n B = FC.jac(st, np.zeros(n))\n G = B @ B.T\n\n # (k) the path links and the section\n des = [(tuple((2 * y[i] + (i == mu)) % S.L for i in range(S.DIM)), mu) for (y, mu) in cons]\n owners = {d: [k for k, (y, mu) in enumerate(cons) if d in S.vlinks(y, mu)] for d in des}\n check(f"(k) each path link d_k is active, in W, and enters only V_k ({tag})",\n all(d in vid for d in des) and all(owners[d] == [k] for k, d in enumerate(des)))\n dset = set(vid[d] for d in des)\n free = [i for i in range(len(var)) if i not in dset]\n fidx = np.concatenate([np.arange(3 * i, 3 * i + 3) for i in free])\n Smat = np.zeros((n, len(fidx)))\n Smat[fidx, np.arange(len(fidx))] = 1.0\n binv = []\n for k, d in enumerate(des):\n r = slice(3 * k, 3 * k + 3)\n dc = slice(3 * vid[d], 3 * vid[d] + 3)\n Bkd = B[r, dc]\n Binv = np.linalg.inv(Bkd)\n binv.append(np.linalg.norm(Binv, 2))\n Bk = B[r, :].copy()\n Bk[:, dc] = 0\n Smat[dc, :] = -Binv @ (Bk @ Smat)\n check(f"(k) B S = 0 (|B S| = {np.max(np.abs(B @ Smat)):.1e}) ({tag})",\n np.max(np.abs(B @ Smat)) <= 1e-12)\n sv = np.linalg.svd(Smat, compute_uv=False)\n check(f"(k) S is injective (least singular value {sv[-1]:.3f} >= 1) and "\n f"dim T = {Smat.shape[1]} = n - 3|K| ({tag})",\n sv[-1] >= 1 - 1e-12 and Smat.shape[1] == n - 3 * len(cons))\n rows = [sum(np.linalg.norm(Smat[3 * vid[d]:3 * vid[d] + 3, 3 * j:3 * j + 3], 2)\n for j in range(len(free))) for d in des]\n check(f"(k) max_k |B_(k,d_k)^-1| = {max(binv):.3f}, path-link row sums of S "\n f"<= {max(rows):.3f} (<= 15.1) ({tag})", max(rows) <= 15.1)\n\n # (m) decay of G^{-1}\n Ginv = np.linalg.inv(G)\n gpairs = [(dist(des[a], des[b]), blocknorm(Ginv, a, b)) for a in range(len(cons))\n for b in range(len(cons))]\n env = envelope(gpairs)\n line = ", ".join(f"{d:g}:{v:.1e}" for d, v in env)\n far = [v for d, v in env if d >= 6]\n check(f"(m) largest block of G^-1 at distance >= d: {line} "\n f"(at d >= 6 at most a hundredth of d = 0) ({tag})", bool(far) and far[0] <= 0.01 * env[0][1])\n\n # (l) and (n): the chart in the coordinate xi\n Gi = np.linalg.inv(G)\n\n def X_of(xi):\n eta = Smat @ xi\n h, _ = FC.solve_h(st, eta, B, Gi)\n return eta + h\n\n rng = st["rng"]\n xi0 = rng.normal(size=len(fidx))\n xi0 *= 0.3 * s / FC.linf(Smat @ xi0)\n X0 = X_of(xi0)\n A = FC.jac(st, X0)\n Pb0 = (np.eye(n) - B.T @ np.linalg.solve(A @ B.T, A)) @ Smat\n lam = np.linalg.eigvalsh(Pb0.T @ Pb0)[0]\n check(f"(l) Pbar^* Pbar >= 1 at a point of the chart (least eigenvalue {lam:.4f}) ({tag})",\n lam >= 1 - 1e-10)\n ppairs = []\n for jcol, i in enumerate(free):\n for a in range(len(var)):\n ppairs.append((dist(var[a], var[i]), blocknorm(Pb0, a, jcol)))\n env = envelope(ppairs)\n line = ", ".join(f"{d:g}:{v:.1e}" for d, v in env if abs(d - round(d)) < 1e-9)\n near = [v for d, v in env if d >= 3]\n far = [v for d, v in env if d >= 8]\n check(f"(m) largest block of Pbar at that point at distance >= d: {line} "\n f"(beyond the range of S it decays: d >= 8 at most a fiftieth of d >= 3) ({tag})",\n bool(far) and far[0] <= 0.02 * near[0])\n\n def Q(xi):\n return FC.Qval(st, X_of(xi))\n\n # pairs of free links along the row, at increasing distance from the first\n first = min(free, key=lambda i: (var[i][0][0], var[i][1]))\n cand = {}\n for i in free:\n d = dist(var[first], var[i])\n if abs(d - round(d)) < 1e-9 and int(round(d)) not in cand and var[i][1] == var[first][1]:\n cand[int(round(d))] = i\n t = 2e-3\n hpairs = []\n for d in sorted(cand):\n i = cand[d]\n ci, cf = free.index(i), free.index(first)\n blk = np.zeros((3, 3))\n for a in range(3):\n for b in range(3):\n va = np.zeros(len(fidx))\n vb = np.zeros(len(fidx))\n va[3 * cf + a] = t\n vb[3 * ci + b] = t\n blk[a, b] = (Q(xi0 + va + vb) - Q(xi0 + va - vb) - Q(xi0 + vb - va) + Q(xi0 - va - vb)) / (4 * t * t)\n hpairs.append((d, np.linalg.norm(blk, 2)))\n line = ", ".join(f"{d}:{v:.1e}" for d, v in hpairs)\n big = [v for d, v in hpairs if d <= 1]\n far = [v for d, v in hpairs if d >= 4]\n check(f"(n) Hessian blocks of Q o X in xi at that point against distance: {line} "\n f"(at d >= 4 at most a hundredth of d <= 1) ({tag})",\n bool(far) and bool(big) and max(far) <= 0.01 * max(big))\n\n\ndef constants():\n k = Fr(1, 10 ** 8)\n check("constants: 1/(1/8 - 260 kappa) <= 8.01 for kappa <= 1e-8", 1 / (Fr(1, 8) - 260 * k) <= Fr(801, 100))\n check("constants: 7/8 + 16/16 = 15/8 and 8.01 (15/8 + sqrt(24) 260e-8) <= 15.1",\n Fr(7, 8) + 1 == Fr(15, 8) and 8.01 * (15 / 8 + np.sqrt(24) * 260e-8) <= 15.1)\n check("constants: 15.1/32 < 1/2 and 15.1 (7/4)/32 < 15/16, 1.75/32 < 1/16",\n Fr(151, 320) < Fr(1, 2) and Fr(151, 10) * Fr(7, 4) / 32 < Fr(15, 16) and Fr(175, 3200) < Fr(1, 16))\n check("constants: v\'\' = 1 on [5r/4, oo) gives v\'(t)/t >= 1 - (5/4)/(3/2) = 1/6 for t >= 3r/2",\n 1 - Fr(5, 4) / Fr(3, 2) == Fr(1, 6))\n check("constants: lambda/30 - c6 >= lambda/60 and 1/60 - 1/120 = 1/120, 2 * 60 = 120",\n Fr(1, 60) - Fr(1, 120) == Fr(1, 120) and 1 / (Fr(1, 120)) == 120)\n\n\nif __name__ == "__main__":\n constants()\n for eps, seed, s in ((1e-3, 11, 1e-2), (1e-2, 12, 3e-2)):\n run(eps, seed, s)\n n_ok = sum(ok for _, ok in checks)\n print(f"{n_ok} of {len(checks)} checks passed")\n', 'compose.py': '"""One step of block averaging in the block-rooted axial gauge: the coarse\ncurvature of the averages, the effective quadratic form of the averages, and\nthe response of the constrained law to a change of one average.\n\nBlocks are 2y + {0,1}^4; tree links as in block_gauge.py. For a field phi the\naverage V_{y,mu}(phi) is the mean over x in B(y) of phi(x,mu) + phi(x+e_mu,mu).\nQ is the sum of squared plaquette curvatures, Q_1 the same on the coarse\nlattice, and S_1(v) = min { Q(phi) : phi = 0 on tree links, V(phi) = v }.\n\nParts:\n (A) Stokes: 16 (dV)_P is the sum over x in B(y) of the curvature of the\n 2 x 2 square from x, each fine plaquette lies in exactly four such\n squares, and Q_1(V(phi)) <= Q(phi) (exact arithmetic, periodic box).\n (B) the extension phi*(v) (v on the 32 links between blocks, zero inside)\n has V(phi*) = v and Q(phi*) = 4 Q_1(v) exactly.\n (C) floating point, comparison only: the eigenvalues of S_1 relative to Q_1\n in the Bloch decomposition lie in [1, 4], tend to 1 at small momentum\n and equal 4 at (pi, pi, 0, 0).\n (D) the bound ||r_w||_1 <= 2 M0 s sqrt(W) <= 4e14 for the response to one\n average, and its floating-point value in the cubes n = 4, 6, 8.\nRun: python3 compose.py. Needs numpy and scipy."""\nimport itertools, math, random, sys\nimport numpy as np\n\nE = np.eye(4, dtype=int)\nOFFS = list(itertools.product(range(2), repeat=4))\nPLANES = [(m, n) for m in range(4) for n in range(m + 1, 4)]\nok = []\n\ndef check(name, cond):\n ok.append(bool(cond)); print((\'ok \' if cond else \'FAIL\'), name)\n\ndef tree(o, mu):\n o = [c % 2 for c in o]\n return o[mu] == 0 and all(o[nu] == 0 for nu in range(mu + 1, 4))\n\n# (A), (B): periodic fine box of side L, coarse side L/2, integer fields\nL = 8; M = L // 2\ndef wrap(x, n): return tuple(int(c) % n for c in x)\ndef curl(f, x, m, n, side):\n x = np.array(x)\n return (f[(wrap(x, side), m)] + f[(wrap(x + E[m], side), n)]\n - f[(wrap(x + E[n], side), m)] - f[(wrap(x, side), n)])\nsites = list(itertools.product(range(L), repeat=4))\ncsites = list(itertools.product(range(M), repeat=4))\nrandom.seed(1)\nphi = {(x, mu): (0 if tree(x, mu) else random.randint(-5, 5)) for x in sites for mu in range(4)}\nV16 = {} # 16 times the averages\nfor y in csites:\n for mu in range(4):\n V16[(y, mu)] = sum(phi[(wrap(2 * np.array(y) + np.array(o), L), mu)]\n + phi[(wrap(2 * np.array(y) + np.array(o) + E[mu], L), mu)] for o in OFFS)\nstokes, cover = True, {}\nfor y in csites:\n for (m, n) in PLANES:\n tot = 0\n for o in OFFS:\n x = 2 * np.array(y) + np.array(o)\n for i, j in itertools.product(range(2), repeat=2):\n z = wrap(x + i * E[m] + j * E[n], L)\n tot += curl(phi, z, m, n, L)\n cover[(z, m, n)] = cover.get((z, m, n), 0) + 1\n stokes &= tot == curl(V16, y, m, n, M)\ncheck(\'(A) 16 (dV)_P = sum of the 16 squares of side two (Stokes)\', stokes)\ncheck(\'(A) every fine plaquette lies in exactly four squares\',\n set(cover.values()) == {4} and len(cover) == len(sites) * 6)\nQ = sum(curl(phi, x, m, n, L) ** 2 for x in sites for (m, n) in PLANES)\nQ1_256 = sum(curl(V16, y, m, n, M) ** 2 for y in csites for (m, n) in PLANES)\ncheck(\'(A) Q_1(V(phi)) <= Q(phi)\', Q1_256 <= 256 * Q)\nprint(f\' Q = {Q}, Q_1 = {Q1_256 / 256:.3f}\')\n\nv = {(y, mu): random.randint(-5, 5) for y in csites for mu in range(4)}\nstar = {}\nfor x in sites:\n y = tuple(c // 2 for c in x); o = tuple(c % 2 for c in x)\n for mu in range(4):\n star[(x, mu)] = v[(y, mu)] if o[mu] == 1 else 0\navg_ok = all(sum(star[(wrap(2 * np.array(y) + np.array(o), L), mu)]\n + star[(wrap(2 * np.array(y) + np.array(o) + E[mu], L), mu)] for o in OFFS)\n == 16 * v[(y, mu)] for y in csites for mu in range(4))\ntree_ok = all(star[(x, mu)] == 0 for x in sites for mu in range(4) if tree(x, mu))\nQs = sum(curl(star, x, m, n, L) ** 2 for x in sites for (m, n) in PLANES)\nQ1v = sum(curl(v, y, m, n, M) ** 2 for y in csites for (m, n) in PLANES)\ncheck(\'(B) phi* vanishes on tree links and V(phi*) = v\', avg_ok and tree_ok)\ncheck(\'(B) Q(phi*) = 4 Q_1(v)\', Qs == 4 * Q1v)\n\n# (C) Bloch decomposition\nlinks = [(o, mu) for o in OFFS for mu in range(4)]\nact = [l for l in links if not tree(*l)]; idx = {l: i for i, l in enumerate(act)}\ndef red(x, mu):\n x = np.array(x); return (tuple(x % 2), mu), tuple(x // 2)\nP = []\nfor o in OFFS:\n x = np.array(o)\n for (mu, nu) in PLANES:\n r = []\n for (yy, m, sg) in [(x, mu, 1), (x + E[mu], nu, 1), (x + E[nu], mu, -1), (x, nu, -1)]:\n l, c = red(yy, m)\n if l in idx: r.append((idx[l], c, sg))\n P.append(r)\nCs = []\nfor mu in range(4):\n r = {}\n for o in OFFS:\n for k in range(2):\n l, c = red(np.array(o) + k * E[mu], mu)\n if l in idx: r[(idx[l], c)] = r.get((idx[l], c), 0) + 1 / 16\n Cs.append([(i, c, val) for (i, c), val in r.items()])\nnA = len(act)\ndef sym(rows, q, ncol):\n Mx = np.zeros((len(rows), ncol), complex)\n for i, r in enumerate(rows):\n for (j, c, val) in r: Mx[i, j] += val * np.exp(1j * np.dot(q, c))\n return Mx\ndef coarse_curl(q):\n D = np.zeros((6, 4), complex)\n for k, (m, n) in enumerate(PLANES):\n D[k, m] += 1; D[k, n] += np.exp(1j * q[m]); D[k, m] -= np.exp(1j * q[n]); D[k, n] -= 1\n return D\ndef ratios(q):\n D = sym(P, q, nA); H = D.conj().T @ D; B = sym(Cs, q, nA)\n u, sv, vh = np.linalg.svd(B); N = vh[(sv > 1e-10).sum():].conj().T\n Bp = np.linalg.pinv(B)\n S1 = Bp.conj().T @ (H - H @ N @ np.linalg.solve(N.conj().T @ H @ N, N.conj().T @ H)) @ Bp\n D1 = coarse_curl(q); Q1 = D1.conj().T @ D1\n w, U = np.linalg.eigh(Q1); R = U[:, w > 1e-9]\n return np.linalg.eigvals(np.linalg.solve(R.conj().T @ Q1 @ R, R.conj().T @ S1 @ R)).real\nlo, hi = 9, 0\nG = 6\nfor qq in itertools.product(range(G), repeat=4):\n if not any(qq): continue\n ev = ratios(2 * np.pi * np.array(qq) / G)\n lo, hi = min(lo, ev.min()), max(hi, ev.max())\nprint(f\' S_1 / Q_1 on the 6^4 grid: [{lo:.6f}, {hi:.6f}]\')\ncheck(\'(C) 1 <= S_1 / Q_1 <= 4 in the Bloch decomposition\', lo >= 1 - 1e-9 and hi <= 4 + 1e-9)\nsmall = ratios(np.array([1e-3, 0, 0, 0])); top = ratios(np.array([np.pi, np.pi, 0, 0]))\nprint(f\' q = (0.001,0,0,0): {small.min():.8f}..{small.max():.8f}; q = (pi,pi,0,0): max {top.max():.8f}\')\ncheck(\'(C) the ratio tends to 1 at small momentum and equals 4 at (pi,pi,0,0)\',\n abs(small.max() - 1) < 1e-5 and abs(top.max() - 4) < 1e-8)\n\n# (D) response to one average\ns, h, b = 96, 24, 1 / 16\nx1 = 1 / (s * math.sqrt(b)); xn = math.hypot(52, 52 * h * x1 + x1)\nyn = (1 + h * xn) / (s * math.sqrt(b)); M0 = math.hypot(xn, yn)\nS = 192; lam = math.log(1 + 1 / (2 * S * M0))\nqd = math.exp(-2 * lam)\nsum3 = qd * (1 + 4 * qd + qd * qd) / (1 - qd) ** 4; sum1 = qd / (1 - qd) ** 2\nW = 4 * math.exp(2 * lam) * (1 + 64 * sum3 + 16 * sum1)\nLw = 2 * 105 * s * math.sqrt(W)\nprint(f\' ||e^(lambda d) r_w|| <= {2 * 105 * s}, ||r_w||_1 <= {Lw:.3e}\')\ncheck(\'(D) ||r_w||_1 <= 4e14\', 2 * 105 * s == 20160 and Lw <= 4e14)\n\nimport scipy.sparse as sp, scipy.sparse.linalg as spl\ndef response(n):\n V = [(x, mu) for x in itertools.product(range(n), repeat=4) for mu in range(4) if not tree(x, mu)]\n vi = {l: i for i, l in enumerate(V)}\n inV = lambda x: all(0 <= c < n for c in x)\n I, J, Dd, r = [], [], [], 0\n for x in itertools.product(range(-1, n), repeat=4):\n xa = np.array(x)\n for (mu, nu) in PLANES:\n ls = [(xa, mu, 1), (xa + E[mu], nu, 1), (xa + E[nu], mu, -1), (xa, nu, -1)]\n ent = [(vi[(tuple(int(c) for c in yy), m)], sg) for (yy, m, sg) in ls\n if (tuple(int(c) for c in yy), m) in vi]\n if ent:\n for (j, sg) in ent: I.append(r); J.append(j); Dd.append(sg)\n r += 1\n D = sp.csr_matrix((Dd, (I, J)), shape=(r, len(V)))\n I, J, Dd, rows = [], [], [], []\n for y in itertools.product(range(n // 2), repeat=4):\n for mu in range(4):\n acc = {}\n for o in OFFS:\n for k in range(2):\n z = tuple(int(c) for c in 2 * np.array(y) + np.array(o) + k * E[mu])\n if (z, mu) in vi: acc[vi[(z, mu)]] = acc.get(vi[(z, mu)], 0) + 1 / 16\n for j, val in acc.items(): I.append(len(rows)); J.append(j); Dd.append(val)\n rows.append((y, mu))\n B = sp.csr_matrix((Dd, (I, J)), shape=(len(rows), len(V)))\n K = sp.bmat([[D.T @ D, B.T], [B, None]]).tocsc()\n c = (n // 4,) * 4; best = 0\n for mu in range(4):\n rhs = np.zeros(K.shape[0]); rhs[len(V) + rows.index((c, mu))] = 1\n best = max(best, np.abs(spl.spsolve(K, rhs)[:len(V)]).sum())\n return best\nfor n in (4, 6, 8):\n print(f\' n = {n}: max ||r_w||_1 for the central block = {response(n):.4f}\')\ncheck(\'(D) floating-point responses computed\', True)\n\nprint(f\'{sum(ok)} checks passed, {len(ok) - sum(ok)} failed\')\nsys.exit(0 if all(ok) else 1)\n', 'composite_free.py': '"""Slice ratio for composite, gauge-invariant slice fields of the free lattice gauge field.\n\nRemark freeslice of the forest paper treats the linear field. The slice field of Sec.\n"Renormalised flowed observables" is a gauge-invariant function of the spatial links of one\nslice, composed with the spatial flow. Its free (abelian, one colour; N^2-1 colours multiply D by\nN^2-1) analogue is the magnetic energy Phi_B(n) = sum_x sum_{i(p) = (d_mu db_rho dl_{nu sigma} - d_mu db_sigma dl_{nu rho}\n - d_nu db_rho dl_{mu sigma} + d_nu db_sigma dl_{mu rho}) / |d|^2;\nthe numerator is c_{-1} e^{-i th} + c_0 + c_1 e^{i th} in the time momentum th, and the inverse\nFourier transform of 1/(2 - 2cos th + m^2) is K(n) = e^{-w|n|}/(2 sinh w), cosh w = 1 + m^2/2,\nso Gt(n) = sum_j c_j K(n+j) exactly. For the magnetic field the numerator does not depend on th.\n\nThe continuum reference is the same sum over the momenta 2 pi n/ell of the torus of side ell,\nwith Gt(r,p) = N(p0 = i|p|) e^{-|p| r}/(2|p|) for r > 0; the infinite-volume continuum value is\nalso printed. Without the flow the continuum ratio is (r/r\')^5 for both fields.\n\n python3 composite_free.py\n"""\nimport itertools\n\nimport numpy as np\n\nSPACE = [(1, 2), (1, 3), (2, 3)]\nALL = [(m, n) for m in range(4) for n in range(m + 1, 4)]\n\n\ndef numer(d, db, mu, nu, rho, sg):\n dl = lambda a, b: 1.0 if a == b else 0.0\n return (d[:, mu] * db[:, rho] * dl(nu, sg) - d[:, mu] * db[:, sg] * dl(nu, rho)\n - d[:, nu] * db[:, rho] * dl(mu, sg) + d[:, nu] * db[:, sg] * dl(mu, rho))\n\n\ndef D_lattice(L, ns, tf_lat, pairs):\n """D(n) for n in ns on an L^3 spatial torus (lattice units), spatial flow time tf_lat."""\n k = 2 * np.pi * np.fft.fftfreq(L)\n p = np.stack(np.meshgrid(k, k, k, indexing="ij"), -1).reshape(-1, 3)\n p = p[np.any(p != 0, axis=1)]\n ds = np.exp(1j * p) - 1.0\n m2 = np.sum(np.abs(ds) ** 2, axis=1)\n w = np.arccosh(1 + m2 / 2)\n flow = np.exp(-2 * tf_lat * m2)\n K = lambda n: np.exp(-w * np.abs(n)) / (2 * np.sinh(w))\n ths = 2 * np.pi * np.arange(3) / 3\n ds_all = [np.concatenate([np.full((len(p), 1), np.exp(1j * th) - 1), ds], axis=1) for th in ths]\n out = np.zeros(len(ns))\n for (mu, nu), (rho, sg) in itertools.product(pairs, pairs):\n vals = np.array([numer(d, np.conj(d), mu, nu, rho, sg) for d in ds_all])\n c = {j: np.mean(vals * np.exp(-1j * j * ths)[:, None], axis=0) for j in (-1, 0, 1)}\n for i, n in enumerate(ns):\n out[i] += np.sum(np.abs(sum(c[j] * K(n + j) for j in (-1, 0, 1)) * flow) ** 2)\n return 2 * out / L ** 3\n\n\ndef D_continuum(ell, rs, tf, pairs, nmax=None):\n """D(r) for r > 0 in the continuum; ell = None is infinite volume (angular average, then a\n radial quadrature), otherwise the torus of side ell."""\n if ell is None:\n rng = np.random.default_rng(0)\n u = rng.normal(size=(20000, 3))\n u /= np.linalg.norm(u, axis=1, keepdims=True)\n d = np.concatenate([-np.ones((len(u), 1)), 1j * u], axis=1)\n db = np.concatenate([np.ones((len(u), 1)), -1j * u], axis=1)\n S = sum(np.abs(numer(d, db, *a, *b)) ** 2 for a, b in itertools.product(pairs, pairs)).mean()\n q = np.linspace(1e-4, 80, 40001)\n return np.array([np.trapezoid(S * q ** 4 / 4 * np.exp(-2 * q * r - 4 * tf * q * q), q)\n for r in rs]) * 2 / (2 * np.pi ** 2)\n nmax = nmax or int(ell * 10)\n k = 2 * np.pi * np.arange(-nmax, nmax + 1) / ell\n p = np.stack(np.meshgrid(k, k, k, indexing="ij"), -1).reshape(-1, 3)\n p = p[np.any(p != 0, axis=1)]\n w = np.linalg.norm(p, axis=1)\n d = np.concatenate([(-w)[:, None], 1j * p], axis=1) # d_0 = i p0 at p0 = i|p|\n db = np.concatenate([w[:, None], -1j * p], axis=1) # conjugate taken before continuation\n S = sum(np.abs(numer(d, db, *a, *b)) ** 2 for a, b in itertools.product(pairs, pairs))\n return np.array([np.sum(S * np.exp(-2 * w * r - 4 * tf * w * w) / (4 * w * w)) for r in rs]) * 2 / ell ** 3\n\n\ndef main():\n rs = np.array([0.25, 0.5, 1.0])\n ell = 6.0\n for name, pairs, spacings in (("magnetic (the paper\'s slice field)", SPACE, (8, 12, 16, 24)),\n ("electric + magnetic", ALL, (8, 12, 16))):\n print(f"== {name}")\n for tf in (0.05, 0.0):\n Di = D_continuum(None, rs, tf, pairs)\n Df = D_continuum(ell, rs, tf, pairs)\n print(f"t_f = {tf}: continuum D(.5)/D(.25), D(1)/D(.5) = {Di[1]/Di[0]:.5f}, {Di[2]/Di[1]:.5f}"\n f" (infinite volume); {Df[1]/Df[0]:.5f}, {Df[2]/Df[1]:.5f} (side {ell})", flush=True)\n for inv_a in spacings:\n L = int(ell * inv_a)\n ns = np.array([0, 1] + [int(round(r * inv_a)) for r in rs])\n D = D_lattice(L, ns, tf * inv_a ** 2, pairs)\n print(f" 1/a={inv_a:3d} L={L:3d}: D(.5)/D(.25)={D[3]/D[2]:.5f} D(1)/D(.5)={D[4]/D[3]:.5f}"\n f" D(a)/D(0)={D[1]/D[0]:.4f} D(.25)/D(0)={D[2]/D[0]:.3e}", flush=True)\n\n\nif __name__ == "__main__":\n main()\n', 'constrained_scales.py': '"""Arithmetic of Theorem "constrainedscales": the constrained cube condition at\nevery scale for the effective forms S_k, with constants independent of k.\nThe inputs are C = 1e26 and eta = 1e-36 of Theorem "effectivelocal", M_0 = 105\nand the weights of Theorem "constrainedcube". Every inequality of the proof is\nevaluated at 80 significant digits, and the counting bounds it uses are\nchecked by enumeration on small cases. Run: python3 constrained_scales.py\n(a few seconds). Needs mpmath."""\nfrom mpmath import mp, mpf, exp, coth, factorial, log10\nfrom itertools import product\nmp.dps = 80\nC, eta, M0 = mpf(10)**26, mpf(10)**-36, 105\nh = 256*24; s = 4*h; lam = mpf(10)**-215\nok = [0, 0]\ndef check(name, cond):\n ok[0 if cond else 1] += 1\n print((\'PASS \' if cond else \'FAIL \') + name)\ndef tail(p, x): # bound for sum_{m>=1} m^p e^{-x m}\n return exp(x)*factorial(p)/x**(p+1)\ndef main():\n # counting facts, by enumeration\n for r in range(1, 9):\n nr = sum(1 for z in product(range(-r, r+1), repeat=4) if sum(map(abs, z)) == r)\n check(\'points with |z|_1 = %d: %d <= 8 r^3\' % (r, nr), nr <= 8*r**3)\n for p in range(5):\n for x in (mpf(\'0.3\'), mpf(1), mpf(2)):\n tot = sum(mpf(m)**p*exp(-x*m) for m in range(1, 4000))\n check(\'sum m^%d e^{-%s m} <= e^x p!/x^(p+1)\' % (p, x), tot <= tail(p, x))\n for n in (2, 4, 10, 30):\n for m in range(1, 8):\n check(\'shell n=%d m=%d\' % (n, m),\n 4*((n+2*m)**4-(n+2*m-2)**4) <= 128*(n**3+8*m**3))\n for m in range(1, 8):\n sites = (2*m+1)**4-(2*m-1)**4\n check(\'sites at l-infinity distance %d: %d = 64m^3+16m\' % (m, sites), sites == 64*m**3+16*m)\n # Lemma saddle: the bounds for (h,s) do not exceed those for (24,96)\n check(\'h/s unchanged\', mpf(h)/s == mpf(24)/96)\n # row sums of Lemma combeslong\n rowH = 24*C*lam*exp(lam)*(1+16*24*exp(eta/2)*(2/eta)**5)\n rows = max(rowH + s*(exp(lam)-1)/8, 2*s*(exp(lam)-1))\n check(\'lambda_1 <= eta/2\', lam <= eta/2)\n check(\'row sums %.3g < 3e-4 < 1/(2 M_0)\' % float(rows), rows < mpf(3)/10**4 < mpf(1)/(2*M0))\n fw = 24*C*exp(lam)*coth((eta-lam)/2)**4\n check(\'|e^{lam d} f| < 4e172 (10^%.3f)\' % float(log10(fw)), fw < 4*mpf(10)**172)\n R2 = (2*M0*(4*mpf(10)**172+exp(lam)*s/16))**2\n check(\'weighted norm squared < 1e350 (10^%.3f)\' % float(log10(R2)), R2 < mpf(10)**350)\n Z = lambda x: 4*exp(x)*(1+384*exp(x)/x**4+16*exp(x)/x**2)\n check(\'Z(lambda_1) < 1e864 (10^%.3f)\' % float(log10(Z(lam))), Z(lam) < mpf(10)**864)\n check(\'l1 bound: 1e350 * Z < 1e1214\', mpf(10)**350*Z(lam) < mpf(10)**1214)\n Lw = 2*M0*s*Z(2*lam)**0.5\n check(\'L_w < 1e438 (10^%.3f)\' % float(log10(Lw)), Lw < mpf(10)**438)\n q = lam/2\n for alpha in (mpf(\'0.99\'), mpf(\'0.5\'), mpf(\'1e-3\'), mpf(\'1e-12\')):\n n = mpf(10)**827/alpha\n K = mpf(10)**607*128*exp(2*q)*(n**3/q+48/q**4)\n check(\'K_c <= alpha N_n at n = 1e827/alpha, alpha=%s (ratio %.3g)\' % (alpha, float(K/(alpha*(n/2)**4))),\n K <= alpha*(n/2)**4)\n print(\'%d checks passed, %d failed\' % tuple(ok))\nif __name__ == \'__main__\':\n main()\n', 'cube_requirements.py': '"""Finite counts behind the subsection on what the cube estimate requires.\n\nThe line field sigma of the residue table has period two. The script checks:\n (a) the table: every plaquette contains exactly one fixed link and every\n active link has twelve active partners;\n (b) the eight lines modulo two, and the colouring of the theorem on the\n cube estimate: residues 0010, 0011, 0100, 0110, 1001, 1011, 1100, 1101\n form four of the eight pairs, and exactly 32 of the 48 active classes\n join residues of different colour (32 is the maximum over all 2^8\n colourings of the pairs);\n (c) the census of (a_c, b_c) over the 48 classes in the boundary count\n a_c m^3 - b_c m^2, and the count itself against direct enumeration of\n boxes of side n = 2, 4, 6, 8, 10;\n (d) the slow line: for each of the 48 line types, the four transverse\n plaquettes at each link have two active links each, off the line, not\n twists, and pairwise distinct over a stretch of the line;\n (e) the exact arithmetic of the proofs;\n (f) the proposition on the cube size: every active link of the cube is the\n holonomy of a disc of at most m(m+1) plaquettes whose other boundary\n links lie in F or outside the cube, each plaquette lies in at most\n 4n^2+2n discs (n = 2, 4, 6, 8), and the lattice Stokes inequality on\n random configurations (n = 2, 4);\n (g) the flux configuration of the remark on loops, in exact angles;\n (h) the arithmetic of the lower bound on eps_V;\n (i) the Gaussian benchmark: K_c = alpha_n(t) N_n for every residue class,\n alpha_n(0) = 1, and the bound for t > 0, in exact arithmetic;\n (j) the joint-cube transport route: a legal configuration where the weighted\n curvature is negative once beta_W > 1/3;\n (k) the four colours of the SU(2) proposition: the sets X_1, ..., X_4 are\n unions of two pairs, every active link joins different sets, X_3 u X_4\n is the colour set of (b), and the tetrahedral quaternions z_k have\n = -1/3 for k != l, in exact arithmetic;\n (l) the four colours for every group: the quotients z_k z_l^{-1} have real\n part -1/3, their images in SU(3) (2x2 block), SU(4) (q tensor I_2) and\n SO(3) have equal Hilbert-Schmidt distance to the identity, and for SU(3)\n the diameter squared is 9 against the Haar mean 6 of the squared distance;\n (m) the cube size for SU(N): every element of SU(N) is exp X with X traceless\n and eigenvalue angles at most 3 pi; the Jacobian of exp in Hilbert-Schmidt\n coordinates is the product of (sin(phi/2)/(phi/2))^2 over pairs of angles\n (finite differences, N = 2, 3, 4); the lower bound\n (11/12)^(N(N-1)) (r/(3 pi sqrt N))^(N^2-1) for the Haar measure of the\n ball of radius r <= 1 against Monte Carlo (N = 2, 3); and the arithmetic\n of L_N(b);\n (n) the proposition on positive reflected norms in a box: the coefficients\n of the SU(2) characters chi_j in exp((b/2) Re chi) are positive for\n 2j <= 4 at b = 0.5 and 2j <= 10 at b = 2, 6 (Weyl integration formula);\n (o) the remarks on the flowed ratio: the free massless covariance with\n spatial cutoff Lambda at time t and at coincidence (radial quadrature),\n and the bounds of the proposition on shifted renormalisation on random\n discrete spectral measures (tail, moments, Lipschitz, Jensen, slab tail);\n (w) two-dimensional SU(N): the holonomy identity and the expansion of the\n character coefficients;\n (x) the proposition on block averages of the free field: the exact\n conditional variance E Var(F | block averages) of a quadratic packet\n against 2 sigma^4 sum alpha_B^2, and Var F against 2 d^2 sum f^2, on\n periodic boxes in two and three dimensions;\n (y) the proposition on perturbed actions: on random finite metric spaces,\n W1 of two measures tilted by the same weight e^u is at most\n e^Omega (1 + 2 Delta l) times W1 of the measures (l the Lipschitz\n constant, Omega the oscillation of u, Delta the diameter), and W1 of one\n measure tilted by e^u and e^u\' is at most 2 Delta sup|u - u\'|, by\n linear programming; and the constants 48, 96 of the proposition;\n (z) gauge-invariant perturbations: the period-two gauge transformation of\n the theorem on the cube estimate maps the configuration equal to Q_V on\n V and 1 elsewhere to one equal to Q^g outside V and to 1 on F, and keeps\n a gauge-invariant weight (the real traces of all 1 x 2 rectangles near\n the cube) unchanged; and in the small-field regime the mean distance of\n the cube links from 1 is at most m(m+1) times the largest plaquette\n distance (n = 2, 4).\nRun: python3 cube_requirements.py\n"""\nfrom collections import Counter\nfrom fractions import Fraction as Fr\nfrom itertools import combinations, product\n\nTABLE = """0000 0 0 2 3 1\n1000 0 0 3 1 2\n0100 2 3 0 2 1\n1100 3 2 0 1 3\n0010 3 1 2 0 3\n1010 1 3 1 0 2\n0110 2 1 3 2 0\n1110 1 2 1 3 0\n0001 1 2 1 3 0\n1001 2 1 3 2 0\n0101 1 3 1 0 2\n1101 3 1 2 0 3\n0011 3 2 0 1 3\n1011 2 3 0 2 1\n0111 0 0 3 1 2\n1111 0 0 2 3 1"""\n\nSIG, NEXT = {}, {}\nfor row in TABLE.splitlines():\n f = row.split()\n r = tuple(int(c) for c in f[0])\n SIG[r] = int(f[1])\n NEXT[r] = [int(c) for c in f[2:]]\n\ndef res(x):\n return tuple(t % 2 for t in x)\n\ndef sigma(x):\n return SIG[res(x)]\n\ndef move(x, mu, s=1):\n return tuple(v + (s if k == mu else 0) for k, v in enumerate(x))\n\ndef active(link):\n return sigma(link[0]) != link[1]\n\ndef plaquette(z, mu, nu):\n return [(z, mu), (move(z, mu), nu), (move(z, nu), mu), (z, nu)]\n\ndef plaquettes_of(link):\n y, mu = link\n out = []\n for nu in range(4):\n if nu != mu:\n for s in (1, -1):\n z = y if s == 1 else move(y, nu, -1)\n out.append((nu, plaquette(z, mu, nu)))\n return out\n\ndef partners(link):\n return {l for _, p in plaquettes_of(link) for l in p if l != link and active(l)}\n\nchecks = 0\ndef ok(cond, msg):\n global checks\n if not cond:\n raise SystemExit("FAILED: " + msg)\n checks += 1\n\n# (a) the table\nfor r in SIG:\n for mu in range(4):\n ok(sigma(move(r, mu)) == NEXT[r][mu], "table column")\n for mu, nu in combinations(range(4), 2):\n ok(sum(not active(l) for l in plaquette(r, mu, nu)) == 1, "one fixed link")\nCLASSES = [(r, mu) for r in SIG for mu in range(4) if SIG[r] != mu]\nok(len(CLASSES) == 48, "48 classes")\nfor c in CLASSES:\n ok(len(partners(c)) == 12, "twelve partners")\n\n# (b) lines modulo two and the colouring\nPAIR = {}\nfor r in SIG:\n r2 = res(move(r, SIG[r]))\n ok(SIG[r2] == SIG[r], "straight lines")\n PAIR[r] = frozenset([r, r2])\nPAIRS = sorted(set(PAIR.values()), key=sorted)\nok(len(PAIRS) == 8, "eight lines modulo two")\nW = {tuple(int(c) for c in s) for s in\n "0010 0011 0100 0110 1001 1011 1100 1101".split()}\nok(all(PAIR[r] <= W for r in W), "W is a union of pairs")\ndef cut(colour):\n return sum(colour(r) != colour(res(move(r, mu))) for r, mu in CLASSES)\nok(cut(lambda r: r in W) == 32, "32 classes cut")\nbest = max(cut(lambda r, b=b: b[PAIRS.index(PAIR[r])])\n for b in product((0, 1), repeat=8))\nok(best == 32, "32 is the maximum")\n\n# (c) the boundary count\ncensus = Counter()\nfor r, mu in CLASSES:\n a = b = 0\n for base, _ in partners((r, mu)):\n d = tuple(u - v for u, v in zip(base, r))\n q = sum((r[l] == 1 and d[l] == 1) or (r[l] == 0 and d[l] == -1)\n for l in range(4))\n a += q\n b += q == 2\n census[(a, b)] += 1\nok(sorted(census.items()) == [((2, 0), 3), ((3, 0), 6), ((4, 0), 6),\n ((5, 0), 6), ((6, 0), 6), ((7, 0), 3), ((7, 1), 3), ((8, 1), 6),\n ((9, 1), 3), ((9, 2), 3), ((10, 2), 3)], "census")\nfor (a, b) in census:\n ok(a <= 10 and 8 - a + b >= 0, "dominated by (10, 2)")\nfor n in (2, 4, 6, 8, 10):\n m = n // 2\n inside = lambda y: all(0 <= t < n for t in y)\n P = Counter()\n for y in product(range(-1, n + 1), repeat=4):\n if inside(y):\n continue\n for mu in range(4):\n if active((y, mu)):\n k = sum(inside(l[0]) for l in partners((y, mu)))\n if k:\n P[(res(y), mu)] += k\n formula = {}\n for r, mu in CLASSES:\n a = b = 0\n for base, _ in partners((r, mu)):\n d = tuple(u - v for u, v in zip(base, r))\n q = sum((r[l] == 1 and d[l] == 1) or (r[l] == 0 and d[l] == -1)\n for l in range(4))\n a += q\n b += q == 2\n formula[(r, mu)] = a * m**3 - b * m**2\n ok(all(P[c] == formula[c] for c in CLASSES), f"box count n={n}")\n ok(max(P.values()) == 10 * m**3 - 2 * m**2, f"maximum n={n}")\n\n# (d) the slow line\nfor x0 in SIG:\n s = SIG[x0]\n for mu in range(4):\n if mu == s:\n continue\n line = [(tuple(v + (k if i == s else 0) for i, v in enumerate(x0)), mu)\n for k in range(30)]\n on = set(line)\n ok(all(active(l) for l in line), "line active")\n twists, others = set(), []\n for link in line[2:-2]:\n for nu, p in plaquettes_of(link):\n rest = [l for l in p if l != link and active(l)]\n ok(sum(not active(l) for l in p) == 1, "fixed link")\n if nu == s:\n nb = [l for l in rest if l in on]\n tw = [l for l in rest if l not in on]\n ok(len(nb) == 1 and len(tw) == 1 and tw[0][1] == s, "twist")\n twists.add(tw[0])\n else:\n ok(len(rest) == 2 and not set(rest) & on, "transverse")\n others += rest\n ok(len(others) == len(set(others)), "transverse links distinct")\n ok(not set(others) & twists, "transverse links are not twists")\n\n# (e) exact arithmetic\nok(Fr(17, 64) + 3 * Fr(17, 64)**2 + Fr(1, 64) == Fr(2019, 4096), "barrier")\nok(Fr(2019, 4096) < Fr(3, 4), "barrier contradiction")\nok(Fr(1, 8) * (2 + Fr(1, 8)) == Fr(17, 64), "eta")\nok(Fr(8, 3 * 4**3) == Fr(1, 24), "ball volume bound with pi < 4")\nbw, n = Fr(3, 10), 16\nok(bw / (1 - 3 * bw) * (Fr(5, n) - Fr(2, n * n)) == Fr(117, 128), "alpha_16")\nr = [(1, 0, 0, 0), (-1, 0, 0, 0), (0, 1, 0, 0), (0, -1, 0, 0), (0, 0, 1, 0),\n (0, 0, -1, 0), (0, 0, 1, 0), (0, -1, 0, 0), (0, 1, 0, 0), (-1, 0, 0, 0)]\nok(all(r[k] == r[(10 - k) % 10] for k in range(10)), "palindrome")\nfor k in range(10):\n h = [Fr(2 * r[k][i] - r[k - 1][i] - r[(k + 1) % 10][i], 2) for i in range(4)]\n ok(sum(t * t for t in h) <= 4, "field at most 2b")\n\n# (f) Proposition on the cube size: links as loops, multiplicity, Stokes\nimport math, random\n\ndef qm(a, b):\n a0, a1, a2, a3 = a\n b0, b1, b2, b3 = b\n return (a0*b0 - a1*b1 - a2*b2 - a3*b3, a0*b1 + a1*b0 + a2*b3 - a3*b2,\n a0*b2 - a1*b3 + a2*b0 + a3*b1, a0*b3 + a1*b2 - a2*b1 + a3*b0)\n\ndef qc(a):\n return (a[0], -a[1], -a[2], -a[3])\n\ndef chord(a): # delta(1, a) = sqrt(2 - Re Tr a), Re Tr a = 2 a_0\n return math.sqrt(max(0.0, 2 - 2 * a[0]))\n\nONE = (1.0, 0.0, 0.0, 0.0)\n\ndef disc(e, n):\n """The disc R(e) of the proof: its plaquettes (base, plane) and its boundary\n as a list of (link, orientation) starting at x."""\n x, mu = e\n m = n // 2\n y = move(x, mu)\n s_, t_ = sigma(x), sigma(y)\n def reach(z, d):\n up, down = n - z[d], z[d] + 1\n return (up, 1) if up <= m else (down, -1)\n s, eps = reach(x, s_)\n t, eps2 = reach(y, t_)\n xp = move(x, s_, s * eps)\n path, pts = [], [x]\n def walk(d, k, sgn):\n for _ in range(k):\n z = pts[-1]\n if sgn == 1:\n path.append(((z, d), 1))\n else:\n path.append(((move(z, d, -1), d), -1))\n pts.append(move(z, d, sgn))\n walk(s_, s, eps) # along the line of F through x\n walk(mu, 1, 1) # to x\' + e_mu\n walk(t_, t, eps2) # along e_tau\n walk(s_, s, -eps) # along e_sigma\n walk(t_, t, -eps2) # back along the line of F through y\n walk(mu, 1, -1) # over e\n plaq = set()\n for a in range(s):\n z = move(x, s_, eps * a if eps == 1 else -(a + 1))\n plaq.add((z, frozenset((s_, mu))))\n for c in range(t):\n w = move(move(y, s_, eps * a if eps == 1 else -(a + 1)), t_,\n c if eps2 == 1 else -(c + 1))\n plaq.add((w, frozenset((s_, t_))))\n return s, t, path, pts, plaq\n\nfor n in (2, 4, 6, 8):\n m = n // 2\n inside = lambda z: all(0 <= v < n for v in z)\n V = [(x, mu) for x in product(range(n), repeat=4) for mu in range(4)\n if active((x, mu))]\n Vset = set(V)\n ok(len(V) == 48 * m**4, f"|V| = 48 N_n, n={n}")\n mult = Counter()\n for e in V:\n x, mu = e\n ok(sigma(move(x, mu)) not in (mu, sigma(x)), "sigma, tau, mu distinct")\n s, t, path, pts, plaq = disc(e, n)\n ok(s <= m and t <= m and len(plaq) == s * (t + 1) <= m * (m + 1), "disc size")\n ok(pts[-1] == x, "closed loop")\n others = [l for l, _ in path[:-1]]\n ok(path[-1][0] == e and e not in others, "e once")\n ok(all(not active(l) or l not in Vset for l in others), "boundary off V")\n for p in plaq:\n mult[p] += 1\n ok(max(mult.values()) <= 4 * n * n + 2 * n, f"multiplicity n={n}")\n if n <= 4:\n rng = random.Random(n)\n U = {}\n for e in V:\n g = [rng.gauss(0, 1) for _ in range(4)]\n r = math.sqrt(sum(v * v for v in g))\n U[e] = tuple(v / r for v in g)\n link = lambda l: U.get(l, ONE)\n def pl(z, a, b):\n return qm(qm(link((z, a)), link((move(z, a), b))),\n qm(qc(link((move(z, b), a))), qc(link((z, b)))))\n for e in V:\n s, t, path, pts, plaq = disc(e, n)\n h = ONE\n for l, o in path:\n h = qm(h, link(l) if o == 1 else qc(link(l)))\n ok(abs(chord(h) - chord(U[e])) < 1e-9, "holonomy is Q_e")\n rhs = sum(chord(pl(z, *sorted(P))) for z, P in plaq)\n ok(chord(h) <= rhs + 1e-9, "lattice Stokes")\nfor n in range(2, 60, 2):\n m = n // 2\n ok(m * (m + 1) * (4 * n * n + 2 * n) * 2 == n * n * (n + 2) * (2 * n + 1),\n "m(m+1)(4n^2+2n) = n^2(n+2)(2n+1)/2")\n ok((n + 2) * (2 * n + 1) <= 5 * n * n, "(n+2)(2n+1) <= 5n^2")\n\n# (g) the flux configuration of the remark: angles in units of 2 pi / L^2\nfor L in (4, 6, 8, 10, 12):\n N = L * L\n phi = 2\n def ang(z, d):\n z = tuple(v % L for v in z)\n if d == 1:\n return (phi * z[0]) % N\n if d == 0 and z[0] == L - 1:\n return (-phi * L * z[1]) % N\n return 0\n def pa(z, a, b):\n return (ang(z, a) + ang(move(z, a), b) - ang(move(z, b), a) - ang(z, b)) % N\n for z in product(range(L), repeat=2):\n for a, b in combinations(range(4), 2):\n zz = (z[0], z[1], 0, 0)\n ok(pa(zz, a, b) == (phi if (a, b) == (0, 1) else 0), "flux plaquettes")\n h, k = 0, L // 2\n for i in range(k):\n h += ang((i, 0, 0, 0), 0) + ang((k, i, 0, 0), 1) \\\n - ang((i, k, 0, 0), 0) - ang((0, i, 0, 0), 1)\n ok(h % N == N // 2, "holonomy -1 on the square")\n ok(phi * k * k == N // 2, "disc bound pi")\n\n# (h) the lower bound on eps_V: 2 e^(1/2) pi^2 (2/9)^3 < 1/2, with e < 2.7183\n# (so e^(1/2) < 1.6488) and pi < 3.1416\nok(Fr(16488, 10000) ** 2 > Fr(27183, 10000), "sqrt(e) < 1.6488")\nok(2 * Fr(16488, 10000) * Fr(31416, 10000) ** 2 * Fr(2, 9) ** 3 < Fr(1, 2), "small ball")\n\n# (i) the Gaussian benchmark: K_c = alpha_n(t) N_n for every class, alpha_n(0) = 1,\n# and the lower bound on 1 - alpha_n(t), in exact arithmetic\ndef solve(M, rhs):\n N = len(M)\n M = [row[:] + [r] for row, r in zip(M, rhs)]\n for c in range(N):\n p = next(r for r in range(c, N) if M[r][c] != 0)\n M[c], M[p] = M[p], M[c]\n inv = 1 / M[c][c]\n M[c] = [v * inv for v in M[c]]\n for r in range(N):\n if r != c and M[r][c] != 0:\n f = M[r][c]\n M[r] = [a - f * b for a, b in zip(M[r], M[c])]\n return [M[r][N] for r in range(N)]\n\nfor d, n in ((1, 2), (1, 6), (2, 2), (2, 4), (2, 6), (3, 2), (3, 4), (4, 2)):\n sites = list(product(range(n), repeat=d))\n index = {x: i for i, x in enumerate(sites)}\n def nbrs(x):\n for i in range(d):\n for s in (1, -1):\n yield tuple(v + (s if k == i else 0) for k, v in enumerate(x))\n ext = sorted({y for x in sites for y in nbrs(x) if y not in index})\n for t in (Fr(0), Fr(1, 3), Fr(2)):\n A = [[Fr(0)] * len(sites) for _ in sites]\n for x in sites:\n A[index[x]][index[x]] = 2 * d + t\n for y in nbrs(x):\n if y in index:\n A[index[x]][index[y]] = Fr(-1)\n Gone = solve(A, [Fr(1)] * len(sites)) # G 1 (A is symmetric)\n alpha = 1 - t * sum(Gone) / n**d\n K = Counter()\n for j in ext:\n C = sum(Gone[index[x]] for x in nbrs(j) if x in index) # 1^T G B_j\n K[tuple(v % 2 for v in j)] += C\n ok(len(K) == 2**d and all(k == alpha * Fr(n // 2) ** d for k in K.values()),\n f"K_c = alpha N_n, d={d} n={n} t={t}")\n if t == 0:\n ok(alpha == 1, "massless alpha = 1")\n else:\n ok(1 - alpha >= Fr(5, 6) ** d * t * n * n / (t * n * n + 10 * d), "mass bound")\n ok(all(g > 0 for g in Gone), "G 1 > 0")\n\n# (j) the joint-cube transport route: at the legal configuration U_j = -1, all\n# other links 1, the six plaquettes through j have holonomy -1, and along a\n# geodesic of SU(2) = S^3 through U_j the action -beta_W sum has\n# second derivative -6 beta_W, against Ricci curvature 2 of the unit S^3:\n# the weighted curvature is negative once beta_W > 1/3, at every cube size\nfor X in ((0, 1, 0, 0), (0, 0, 1, 0), (0, 0, 0, 1), (0, 0.6, 0, 0.8)):\n for beta in (0.2, 1 / 3, 0.5, 2.3):\n def act(s):\n u = qm((-1, 0, 0, 0), (math.cos(s),) + tuple(math.sin(s) * c for c in X[1:]))\n return -beta * 6 * u[0] # six plaquettes, = Re part\n h = 1e-4\n second = (act(h) - 2 * act(0) + act(-h)) / h**2\n ok(abs(second + 6 * beta) < 1e-5, "second derivative -6 beta_W")\n ok((2 + second < 0) == (beta > 1 / 3 + 1e-12), "curvature sign at 1/3")\nok(Fr(4, 29) < Fr(1, 3), "Bakry-Emery range 4/29 below the threshold 1/3")\n\n# (k) four colours for SU(2)\nXS = [{tuple(int(c) for c in w) for w in ws.split()} for ws in (\n "0000 1000 0111 1111", "0001 0101 1010 1110",\n "0010 0011 1100 1101", "0100 0110 1001 1011")]\nok(sorted(r for X in XS for r in X) == sorted(SIG), "four sets partition the residues")\ncolour = {r: k for k, X in enumerate(XS) for r in X}\nfor X in XS:\n ok(all(res(move(r, SIG[r])) in X for r in X), "union of pairs")\nfor r in SIG:\n for mu in range(4):\n if mu != SIG[r]:\n ok(colour[r] != colour[res(move(r, mu))], "active link joins different sets")\nok(XS[2] | XS[3] == {tuple(int(c) for c in w) for w in\n "0010 0011 0100 0110 1001 1011 1100 1101".split()}, "X3 u X4 is the colour set of (b)")\nZ = [(1, 1, 1), (1, -1, -1), (-1, 1, -1), (-1, -1, 1)]\nfor k, l in combinations(range(4), 2):\n ok(Fr(sum(a * b for a, b in zip(Z[k], Z[l])), 3) == Fr(-1, 3), " = -1/3")\nok(2 - 2 * Fr(-1, 3) == Fr(8, 3), "d_*^2 = 8/3")\n\n# (l) four colours for every group\nimport numpy as np\ndef su2(q):\n a, b, c, d = q\n return np.array([[a + 1j * b, c + 1j * d], [-c + 1j * d, a - 1j * b]])\nZQ = [(0,) + tuple(v / math.sqrt(3) for v in z) for z in Z]\ndef so3(q):\n a, b, c, d = q\n return np.array([[a*a+b*b-c*c-d*d, 2*(b*c-a*d), 2*(b*d+a*c)],\n [2*(b*c+a*d), a*a-b*b+c*c-d*d, 2*(c*d-a*b)],\n [2*(b*d-a*c), 2*(c*d+a*b), a*a-b*b-c*c+d*d]])\nembed = {"SU(3)": lambda q: np.block([[su2(q), np.zeros((2, 1))], [np.zeros((1, 2)), np.eye(1)]]),\n "SU(4)": lambda q: np.kron(su2(q), np.eye(2)),\n "SO(3)": so3}\nfor name, phi in embed.items():\n dist = []\n for k in range(4):\n for l in range(4):\n if k != l:\n quo = qm(ZQ[k], qc(ZQ[l]))\n ok(abs(quo[0] + 1 / 3) < 1e-12, "real part -1/3")\n M = phi(ZQ[k]) @ np.conj(phi(ZQ[l])).T\n dist.append(np.linalg.norm(M - np.eye(M.shape[0])))\n ok(max(dist) - min(dist) < 1e-12 and min(dist) > 0.5, "equal positive distances " + name)\nbest = min(math.cos(a) + math.cos(b) + math.cos(a + b)\n for a in np.linspace(0, 2 * math.pi, 721) for b in np.linspace(0, 2 * math.pi, 721))\nok(abs(best + 1.5) < 1e-9, "min Re tr on SU(3) is -3/2")\nok(6 + 2 * Fr(3, 2) == 9 and Fr(6, 3) == Fr(2, 3) * 3, "SU(3): D^2 = 9, 2d/D = (2/3) D")\n\n# (m) the cube size for SU(N)\nrng = np.random.default_rng(20261028)\ndef haar_su(N, k):\n Zm = (rng.standard_normal((k, N, N)) + 1j * rng.standard_normal((k, N, N))) / math.sqrt(2)\n Qm, Rm = np.linalg.qr(Zm)\n dg = np.diagonal(Rm, axis1=1, axis2=2)\n Qm = Qm * (dg / abs(dg))[:, None, :]\n return Qm / (np.linalg.det(Qm) ** (1 / N))[:, None, None]\ndef expm_h(X): # X skew-Hermitian\n w, U = np.linalg.eigh(-1j * X)\n return (U * np.exp(1j * w)) @ np.conj(U).T\ndef basis_su(N): # Hilbert-Schmidt orthonormal basis of su(N)\n B = []\n for j in range(N):\n for k in range(j + 1, N):\n E = np.zeros((N, N), complex); E[j, k] = 1; E[k, j] = -1; B.append(E / math.sqrt(2))\n E = np.zeros((N, N), complex); E[j, k] = 1j; E[k, j] = 1j; B.append(E / math.sqrt(2))\n for j in range(1, N):\n E = np.zeros((N, N), complex)\n for k in range(j): E[k, k] = 1j\n E[j, j] = -1j * j; B.append(E / np.linalg.norm(E))\n return B\nfor N in (2, 3, 4):\n for q in haar_su(N, 20):\n w, U = np.linalg.eig(q)\n th = np.angle(w)\n th = np.where(th >= math.pi, th - 2 * math.pi, th)\n kk = int(round(th.sum() / (2 * math.pi)))\n order = np.argsort(th)\n if kk > 0: th[order[-kk:]] -= 2 * math.pi\n if kk < 0: th[order[:-kk]] += 2 * math.pi\n ok(abs(th.sum()) < 1e-9 and max(abs(th)) <= 3 * math.pi, "angles traceless, at most 3 pi")\n ok(np.linalg.norm((U * np.exp(1j * th)) @ np.linalg.inv(U) - q) < 1e-8, "exp X = q")\n B = basis_su(N)\n G = np.array([[np.trace(np.conj(a).T @ b).real for b in B] for a in B])\n ok(np.allclose(G, np.eye(N * N - 1)), "orthonormal basis of su(N)")\n for _ in range(5):\n c = rng.standard_normal(N * N - 1); c *= rng.uniform(0.1, 2.5) / np.linalg.norm(c)\n X = sum(a * b for a, b in zip(c, B))\n E0inv = np.conj(expm_h(X)).T\n h = 1e-6\n J = np.array([[np.trace(np.conj(Bb).T @ (E0inv @ (expm_h(X + h * Ba) - expm_h(X - h * Ba)) / (2 * h))).real\n for Ba in B] for Bb in B])\n ang = np.linalg.eigvalsh(-1j * X)\n prod = 1.0\n for a, b in combinations(ang, 2):\n x = (a - b) / 2\n prod *= (math.sin(x) / x) ** 2\n ok(abs(abs(np.linalg.det(J)) - prod) < 1e-5, f"Jacobian of exp, N = {N}")\n if np.linalg.norm(X) <= 1:\n ok(prod >= (11 / 12) ** (N * (N - 1)), "Jacobian at least (11/12)^(N(N-1))")\nfor N, r in ((2, 0.6), (3, 0.9)):\n dim = N * N - 1\n lower = (11 / 12) ** (N * (N - 1)) * (r / (3 * math.pi * math.sqrt(N))) ** dim\n hits = total = 0\n for _ in range(20):\n Qs = haar_su(N, 50000)\n d2 = np.sum(abs(Qs - np.eye(N)) ** 2, axis=(1, 2))\n hits += int(np.sum(d2 <= r * r)); total += len(d2)\n ok(hits / total > lower, f"ball measure above the bound, N = {N}")\nfor N in (2, 3, 4, 5):\n for bb in (N / 9, 1, 6, 100):\n r = math.sqrt(N / (9 * bb))\n lhs = (N * N - 1) / 2 * math.log(9 * bb / N) + (N * N - 1) * math.log(3 * math.pi * math.sqrt(N))\n ok(abs(lhs - (N * N - 1) / 2 * math.log(81 * math.pi ** 2 * bb)) < 1e-9, "L_N arithmetic")\n ok(abs(math.log(3 * math.pi * math.sqrt(N) / r) - 0.5 * math.log(81 * math.pi ** 2 * bb)) < 1e-9, "radius")\nok(all(math.sin(x) / x >= 1 - x * x / 6 for x in np.linspace(1e-6, 1 / math.sqrt(2), 1000)), "sin x / x >= 1 - x^2/6")\n\n# (n) positive character coefficients of the Wilson weight for SU(2)\nth = np.linspace(0, math.pi, 20001)\nwts = (2 / math.pi) * np.sin(th) ** 2\ntrap = getattr(np, "trapezoid", None) or getattr(np, "trapz")\nfor bb, top in ((0.5, 4), (2.0, 10), (6.0, 10)):\n dens = np.exp(bb * np.cos(th)) # (b/N) Re chi = (b/2) 2 cos theta\n for twoj in range(top + 1):\n chi = np.sin((twoj + 1) * th[1:-1]) / np.sin(th[1:-1])\n c = trap(dens[1:-1] * chi * wts[1:-1], th[1:-1])\n ok(c > 0, f"positive character coefficient, b = {bb}, 2j = {twoj}")\n\n# (o) the flowed ratio\nfor Lam, t in ((1.0, 0.5), (10.0, 0.3), (100.0, 1.0)):\n p = np.linspace(0, Lam, 400001)\n num = trap(p * np.exp(-p * t), p) / (4 * math.pi ** 2)\n ok(abs(num - (1 - (1 + Lam * t) * math.exp(-Lam * t)) / (4 * math.pi ** 2 * t * t)) < 1e-8 * max(1, num), "C(t,0)")\n ok(abs(trap(p, p) / (4 * math.pi ** 2) - Lam ** 2 / (8 * math.pi ** 2)) < 1e-8 * Lam ** 2, "C(0,0)")\nok(2 * (1 - (1 + 1e4) * math.exp(-1e4)) / 1e8 < 1e-7, "contact ratio tends to zero")\nfor trial in range(200):\n E = rng.exponential(rng.uniform(0.5, 20), 30); w = rng.dirichlet(np.ones(30))\n sig = rng.uniform(0.2, 2); R = float(np.sum(w * np.exp(-sig * E)))\n wp = w * np.exp(-sig * E) / R\n for Lam in (0.5, 2, 8):\n ok(np.sum(wp[E >= Lam]) <= np.exp(-sig * Lam) / R + 1e-12, "tail")\n for m in (1, 2, 3):\n ok(np.sum(wp * E ** m) <= (m / (math.e * sig)) ** m / R + 1e-9, "moments")\n ts = rng.uniform(0, 3, 2)\n ok(abs(np.sum(wp * (np.exp(-ts[0] * E) - np.exp(-ts[1] * E)))) <= abs(ts[0] - ts[1]) / (math.e * sig * R) + 1e-12, "Lipschitz")\n a = rng.uniform(0.001, 0.05); d = float(np.sum(w * (1 - np.exp(-a * E)))); C = d / a\n for n in (1, 5, 40):\n if C * a <= 0.5:\n ok(np.sum(w * np.exp(-a * n * E)) >= math.exp(-2 * C * a * n) - 1e-12, "Jensen")\n for Lam in (0.5, 2, 8):\n ok(np.sum(w[E >= Lam]) <= C * (a + 1 / Lam) + 1e-12, "slab tail")\n\n# (p) packet ratio against slice correlators: D(2 a n1 + s)/D(2 a n0) <= C(s)/C(0)\n# <= D(2 a n0 + s)/D(2 a n1), log-convexity, and the extension from one pair\ndef lse(x):\n return float(np.logaddexp.reduce(np.asarray(x, dtype=float)))\nfor trial in range(400):\n a = 10 ** rng.uniform(-3, -1); K = int(rng.integers(1, 40))\n ll = -a * 10 ** rng.uniform(-1, 3.5, K); lnu = np.log(rng.exponential(size=K))\n t0 = rng.uniform(0.05, 1); t1 = t0 + rng.uniform(0.01, 1)\n n0 = int(np.ceil(t0 / a)); n1 = int(np.floor(t1 / a))\n if n1 <= n0:\n continue\n n = np.arange(n0, n1 + 1); lw = np.log(rng.uniform(1e-3, 1, len(n)) * a)\n lW = np.array([lse(lw + l * n) for l in ll])\n lD = lambda j: lse(lnu + ll * j)\n lC = lambda m: lse(lnu + 2 * lW + ll * m)\n m = int(rng.uniform(0.05, 2) / a); r = lC(m) - lC(0)\n ok(lD(2 * n1 + m) - lD(2 * n0) - 1e-9 <= r <= lD(2 * n0 + m) - lD(2 * n1) + 1e-9, "slice bounds")\n j = int(rng.integers(1, 200)); ok(2 * lD(j) <= lD(j - 1) + lD(j + 1) + 1e-9, "log-convex D")\n ok(2 * lC(j) <= lC(j - 1) + lC(j + 1) + 1e-9, "log-convex C")\n i0, i1 = sorted(rng.choice(300, 2, replace=False)); lc = lD(i1) - lD(i0)\n al = int(rng.integers(i0, 400)); be = al + int(rng.integers(1, 400))\n ok(lD(be) - lD(al) >= lc * max(1, (be - al) / (i1 - i0)) - 1e-9, "extension from one pair")\n\n# (q) the free lattice field: D_k(tau\')/D_k(tau) converges to the continuum ratio\ndef slice_corr(a, tau, tf=0.05, N=128):\n L = np.pi / a; P = min(L, 8.0); ps = np.linspace(-P, P, N, endpoint=False) + P / N\n px, py, pz = np.meshgrid(ps, ps, ps, indexing=\'ij\')\n ph2 = sum((2 / a * np.sin(a * q / 2)) ** 2 for q in (px, py, pz))\n w = np.arccosh(1 + a * a * ph2 / 2) / a\n hh = np.zeros_like(px)\n for kx in (-1, 0, 1):\n for ky in (-1, 0, 1):\n for kz in (-1, 0, 1):\n hh += np.exp(-((px + 2 * L * kx) ** 2 + (py + 2 * L * ky) ** 2 + (pz + 2 * L * kz) ** 2) / 4)\n return np.sum(hh ** 2 * np.exp(-2 * tf * ph2) * np.exp(-tau * w) / (2 * np.sinh(a * w) / a))\nx = np.linspace(1e-6, 30, 300001)\ncont = [trap(x * x * np.exp(-x * x / 2 - 2 * 0.05 * x * x - t * x) / (2 * x), x) for t in (0.5, 1.0)]\nrc = cont[1] / cont[0]\nok(abs(rc - 0.63365) < 1e-4, "continuum free ratio")\nfor a in (0.1, 0.0125, 0.001):\n ok(abs(slice_corr(a, 1.0) / slice_corr(a, 0.5) - rc) < 2e-3, f"lattice free ratio, a = {a}")\nth = np.linspace(1e-9, 6, 100001)\nok(np.all(np.arccosh(1 + th) >= math.acosh(7) / math.sqrt(12) * np.sqrt(2 * th) - 1e-12), "arccosh bound")\n\n# (r) the three-state chain: two-point e^{-mt}, four-point q1 q3 (q2/eps + 1 - q2)\nfrom fractions import Fraction as Fr\nfor eps in (Fr(1, 2), Fr(1, 10), Fr(1, 1000)):\n pi = {-1: eps / 2, 0: 1 - eps, 1: eps / 2}\n S = (-1, 0, 1)\n def P(q, s, t):\n return q * (s == t) + (1 - q) * pi[t]\n for q1, q2, q3 in ((Fr(1, 2), Fr(1, 2), Fr(1, 2)), (Fr(1, 3), Fr(3, 4), Fr(2, 5)), (Fr(9, 10), Fr(1, 7), Fr(1, 1))):\n ok(all(pi[s] * P(q1, s, t) == pi[t] * P(q1, t, s) for s in S for t in S), "detailed balance")\n two = sum(pi[s] * s * P(q1, s, t) * t for s in S for t in S) / eps\n ok(two == q1, "two-point")\n four = sum(pi[s0] * s0 * P(q1, s0, s1) * s1 * P(q2, s1, s2) * s2 * P(q3, s2, s3) * s3\n for s0 in S for s1 in S for s2 in S for s3 in S) / eps ** 2\n ok(four == q1 * q3 * (q2 / eps + 1 - q2), "four-point")\n ok(four - q1 * q3 - 2 * q1 * q2 ** 2 * q3 == q1 * q3 * (q2 / eps - q2 - 2 * q2 ** 2), "truncated four-point")\n\n# (s) the range of the slice-ratio extension, and the later-pair counterexample\nD = lambda t: (Fr(1, 2) ** t + Fr(1, 4) ** t) / 2\nc = D(3) / D(1)\nok(c == Fr(3, 16) and D(2) / D(1) == Fr(5, 12), "slice values")\nok((D(2) / D(1)) ** 2 < c, "power bound fails inside the pair")\nok(D(2) / D(1) >= c, "monotone bound inside the pair")\nfor al, be in ((1, 4), (2, 5), (1, 7), (3, 9)):\n ok(D(be) / D(al) >= c ** Fr(max(2, be - al), 2) if (be - al) % 2 == 0 else\n (D(be) / D(al)) ** 2 >= c ** max(2, be - al), "power bound to the right")\nfor k in (10, 20, 40):\n Dk = lambda t: (1 - Fr(1, 4 ** k)) * Fr(1, 2 ** (k * t)) + Fr(1, 4 ** k) * Fr(1, 2 ** t)\n ok(abs(Dk(4) / Dk(3) - Fr(1, 2)) < Fr(1, 2 ** (k - 2)), "later pair ratio near 1/2")\n ok(Dk(2) / Dk(1) < Fr(2, 2 ** k), "earlier pair ratio tends to zero")\n# (t) the amplitude scales cancel: r^n (c r^2 V)^(-n/2) V^(n-1) = c^(-n/2) V^(n/2-1)\nfor r in (Fr(1, 7), Fr(3, 2), Fr(10 ** -6)):\n for V in (Fr(1, 3), Fr(5, 1)):\n for n in (2, 4, 6):\n lhs = r ** n * V ** (n - 1) / (r * r * V) ** (n // 2)\n ok(lhs == V ** (n // 2 - 1), "amplitude cancels")\n\n# (u) tree bounds force a closing gap: C(s)/C(0) <= e^{-m s/a} for spectral measures on\n# Omega^perp, and the product-form tail ratio 2 e^{-mu R\'}/(1 + e^{-mu}) <= 2 e^{-mu R}\nfor trial in range(300):\n a = 10 ** rng.uniform(-3, -1); m = rng.uniform(0, 3); K = int(rng.integers(1, 30))\n lam = np.exp(-m) * rng.uniform(0, 1, K); w = rng.exponential(size=K); w /= w.sum()\n s = a * int(rng.integers(1, 400))\n ok(float(np.sum(w * lam ** round(s / a))) <= math.exp(-m * s / a) + 1e-15, "gap bound")\nfor mu in (Fr(1, 3), Fr(1, 1), Fr(5, 2)):\n q = math.exp(-float(mu))\n for R in (0.5, 3.0, 7.25, 20.0):\n Rp = math.ceil(R); J = 4000\n tail = sum(q ** abs(j) for j in range(-J, J + 1) if abs(j) >= Rp)\n full = sum(q ** abs(j) for j in range(-J, J + 1))\n ok(abs(tail / full - 2 * q ** Rp / (1 + q)) < 1e-12, "tail fraction")\n ok(tail / full <= 2 * math.exp(-float(mu) * R) + 1e-15, "tail bound")\n ok((1 + q) / (1 - q) >= 2 / float(mu), "coth bound")\n\n# (v) energy control from the order-two tree bounds, uniform local estimates, blocking:\n# finite differences, 1 - e^{-x} >= x/(1+x), log(1-x) >= -2x, the SU(2) one-link\n# constants, the Bessel majorant, and |Tr(T^2 M)| <= 1 for unit T and unitary M\nfrom scipy.special import iv, ive\nfrom scipy.integrate import quad\nfor m in (1, 2, 3):\n for a in (0.1, 0.01):\n xs = np.linspace(0.3, 2.0, 50)\n f = lambda x: np.exp(-1 / (x * (2.3 - x))) if 0 < x < 2.3 else 0.0\n D = [sum((-1) ** j * math.comb(m, j) * f(x - j * a) for j in range(m + 1)) for x in xs]\n h = 1e-3; g = np.linspace(0.01, 2.29, 4000)\n der = [max(abs(sum((-1) ** j * math.comb(m, j) * f(y + (m / 2 - j) * h) for j in range(m + 1)) / h ** m) for y in g)]\n ok(max(abs(d) for d in D) <= a ** m * der[0] * 1.05 + 1e-12, "finite difference")\nfor x in np.linspace(0, 50, 501):\n ok(1 - math.exp(-x) >= x / (1 + x) - 1e-15, "1 - e^-x")\nfor x in np.linspace(0, 0.5, 101):\n ok(math.log1p(-x) >= -2 * x - 1e-15, "log(1-x)")\nok(math.e ** 2 * math.sqrt(math.pi / 2) < 14, "Z_T bound")\nok(4 * 224 * 336 < 2 ** 19 and 1792 * 1 <= 2 ** 19, "variance constants")\nok(math.exp(-0.5) / 8 >= 1 / 16 and math.exp(-1.5) / 4 >= 1 / 24, "interval masses")\nfor r in np.concatenate([np.linspace(0, 10, 41), [30.0, 100.0, 600.0]]):\n n = 1 + r\n br = [k / n for k in (1, 4, 16, 64) if k / n < 2]\n Z = quad(lambda t: math.exp(-r * t) * math.sqrt(t * (2 - t)), 0, 2, limit=200, points=br)[0]\n ok(Z <= 14 * n ** -1.5, "normalisation")\n pI = quad(lambda t: math.exp(-r * t) * math.sqrt(t * (2 - t)), 1 / (4 * n), 1 / (2 * n))[0] / Z\n pJ = quad(lambda t: math.exp(-r * t) * math.sqrt(t * (2 - t)), 1 / n, 1.5 / n)[0] / Z\n ok(pI >= 1 / 224 and pJ >= 1 / 336, "P(I), P(J)")\n m1 = quad(lambda t: t * math.exp(-r * t) * math.sqrt(t * (2 - t)), 0, 2, limit=200, points=br)[0] / Z\n m2 = quad(lambda t: t * t * math.exp(-r * t) * math.sqrt(t * (2 - t)), 0, 2, limit=200, points=br)[0] / Z\n ok(m2 - m1 ** 2 >= 1 / (2 ** 19 * n * n), "Var X")\n EX = 1 - m1\n if r > 0:\n ok(abs(EX - iv(2, r) / iv(1, r)) < 1e-7, "E X = I2/I1")\n ok(abs(3 * EX - r * (2 * m1 - m2)) < 1e-8 * (1 + r), "sphere identity")\n ok(EX <= (math.sqrt(9 + 4 * r * r) - 3) / (2 * r) + 1e-12 <= 2 * r / (2 * r + 3) + 1e-12, "mean bound")\n ok(all(iv(l + 1, r) <= iv(2, r) * (1 + 1e-12) for l in range(1, 8)), "Bessel order")\nfor b in (0.5, 1.0, 5.0, 50.0):\n ok(2 * 6 * b / (2 * 6 * b + 3) <= 4 * b / (4 * b + 1) + 1e-15 and 3 / (12 * b + 3) >= 1 / (4 * b + 1) - 1e-15, "b bounds")\n for B in (4, 10, 100):\n ok(math.exp(3 * b) * (4 * b / (4 * b + 1)) ** (B - 3) <= math.exp(3 * b - (B - 3) / (4 * b + 1)) * (1 + 1e-12), "blocking bound")\nfor N in (2, 3, 4):\n for trial in range(40):\n X = rng.normal(size=(N, N)) + 1j * rng.normal(size=(N, N)); T = X - X.conj().T\n T -= np.trace(T) / N * np.eye(N); T /= math.sqrt(-np.trace(T @ T).real)\n M = np.linalg.qr(rng.normal(size=(N, N)) + 1j * rng.normal(size=(N, N)))[0]\n ok(abs(np.trace(T @ T @ M)) <= 1 + 1e-12, "|Tr(T^2 M)| <= 1")\n\n# (w) two-dimensional SU(N): the holonomy identity, chat_lambda = 1 - N C2/beta + O(beta^-2)\n# (SU(2) by Bessel functions, SU(3) fundamental and adjoint by Weyl integration), and the\n# energies -(ell/a^2) log chat_F -> g^2 ell C2/2 at beta = 2N/(g^2 a^2)\ndef haar(N):\n Z = (rng.normal(size=(N, N)) + 1j * rng.normal(size=(N, N))) / math.sqrt(2)\n Q, R = np.linalg.qr(Z); Q = Q * (np.diag(R) / abs(np.diag(R)))\n return Q / np.linalg.det(Q) ** (1 / N)\nfor N in (2, 3):\n for L in (2, 3, 5):\n V = [haar(N) for _ in range(L)]; W = [haar(N) for _ in range(L)]\n lhs = np.eye(N); rhs = np.eye(N); P = np.eye(N)\n for x in range(L):\n lhs = lhs @ (W[x] @ V[x]); rhs = rhs @ (P @ W[x] @ np.linalg.inv(P)); P = P @ V[x]\n ok(np.allclose(lhs, rhs @ P), "holonomy identity")\nfor beta in (400.0, 1600.0, 6400.0):\n c = ive(2, beta) / ive(1, beta)\n ok(abs(beta * (1 - c) / 2 - 0.75) < 1.0 / beta, "SU(2) chat")\nth = np.linspace(-np.pi, np.pi, 1600, endpoint=False)\nt1, t2 = np.meshgrid(th, th, indexing="ij"); t3 = -(t1 + t2)\nz = [np.exp(1j * t1), np.exp(1j * t2), np.exp(1j * t3)]\nvd = abs(z[0] - z[1]) ** 2 * abs(z[0] - z[2]) ** 2 * abs(z[1] - z[2]) ** 2\nchi = z[0] + z[1] + z[2]; retr = np.cos(t1) + np.cos(t2) + np.cos(t3)\nfor beta in (800.0, 3200.0):\n w = vd * np.exp(beta / 3 * (retr - 3)); w /= w.sum()\n cF = float(np.sum(w * chi).real) / 3; cA = float(np.sum(w * (abs(chi) ** 2 - 1))) / 8\n ok(abs(beta * (1 - cF) / 3 - 4 / 3) < 40 / beta and abs(beta * (1 - cA) / 3 - 3) < 80 / beta, "SU(3) chat")\n ok(0 < cA < cF < 1, "SU(3) chat order")\nfor a in (0.02, 0.01, 0.005):\n beta = 4 / a ** 2\n E = -math.log(ive(2, beta) / ive(1, beta)) / a ** 2\n ok(abs(E - 0.375) < 0.4 * a, "SU(2) energy")\n\n# (x) block averages of the free field: E Var(F|B) >= 2 sigma^4 sum alpha_B^2 and\n# Var F <= 2 d^2 sum f^2, exactly by Gaussian traces\ndef free_block_check(shape, mu, fvals, blocks):\n d = len(shape); sites = list(product(*[range(n) for n in shape])); idx = {x: i for i, x in enumerate(sites)}\n n = len(sites)\n def mv(x, nu, s):\n y = list(x); y[nu] = (y[nu] + s) % shape[nu]; return tuple(y)\n P = np.zeros((n, n))\n for x in sites:\n P[idx[x], idx[x]] += 2 * d + mu ** 2\n for nu in range(d):\n for s_ in (1, -1):\n P[idx[x], idx[mv(x, nu, s_)]] -= 1\n C = np.linalg.inv(P)\n A = np.zeros((n, n))\n for x in sites:\n for nu in range(d):\n g = np.zeros(n); g[idx[mv(x, nu, 1)]] += 1; g[idx[x]] -= 1\n A += fvals[idx[x]] * np.outer(g, g)\n K = np.zeros((len(blocks), n))\n for b, z in enumerate(blocks):\n for e in product((0, 1), repeat=d):\n K[b, idx[tuple((2 * z[i] + e[i]) % shape[i] for i in range(d))]] = 2.0 ** -d\n Cc = C - C @ K.T @ np.linalg.solve(K @ C @ K.T, K @ C)\n evar = 2 * np.trace(A @ Cc @ A @ Cc) + 4 * np.trace(A @ Cc @ A @ (C - Cc))\n var = 2 * np.trace(A @ C @ A @ C)\n sig2 = 2 / (2 * d + mu ** 2); al = 0.0\n for z in blocks:\n xb = tuple(2 * zi for zi in z); yb = tuple(2 * z[i] + (1 if i < 2 else 0) for i in range(d))\n t = sum(d * fvals[idx[w]] + sum(fvals[idx[mv(w, nu, -1)]] for nu in range(d)) for w in (xb, yb))\n al += (t / 4) ** 2\n ok(evar >= 2 * sig2 ** 2 * al * (1 - 1e-9), "block-average lower bound")\n ok(var <= 2 * d * d * float(np.sum(fvals ** 2)) * (1 + 1e-9), "variance upper bound")\n ok(evar <= var * (1 + 1e-9), "conditioning reduces variance")\nfor shape in ((4, 4), (6, 6), (8, 4), (4, 4, 4)):\n allb = list(product(*[range(n // 2) for n in shape]))\n for mu in (0.1, 0.7, 2.0):\n for trial in range(3):\n fv = rng.random(int(np.prod(shape))) * (rng.random(int(np.prod(shape))) < 0.6)\n sub = [b for b in allb if rng.random() < 0.7] or allb[:1]\n free_block_check(shape, mu, fv, sub)\n\n# (y) perturbed actions: the tilt inequalities behind the openness of D(n, alpha)\nfrom scipy.optimize import linprog\ndef w1(mu, nu, Dm):\n k = len(mu)\n A_eq = []; b_eq = []\n for i in range(k):\n row = np.zeros(k * k); row[i * k:(i + 1) * k] = 1; A_eq.append(row); b_eq.append(mu[i])\n for j in range(k):\n row = np.zeros(k * k); row[j::k] = 1; A_eq.append(row); b_eq.append(nu[j])\n r = linprog(Dm.ravel(), A_eq=np.array(A_eq), b_eq=np.array(b_eq), bounds=(0, None), method="highs")\n return r.fun\ndef tilt(mu, u):\n h = mu * np.exp(u - u.max()); return h / h.sum()\nyrng = np.random.default_rng(29102026)\nfor trial in range(60):\n k = int(yrng.integers(4, 9))\n pts = yrng.normal(size=(k, 4)); pts /= np.linalg.norm(pts, axis=1)[:, None]\n Dm = np.arccos(np.clip(pts @ pts.T, -1, 1)) # geodesic metric on S^3 = SU(2)\n Delta = Dm.max()\n ell = float(yrng.uniform(0.05, 2.0))\n cen = yrng.integers(0, k, size=3); off = yrng.uniform(0, 1, size=3)\n u = ell * np.min(off[None, :] + Dm[:, cen], axis=1) # ell-Lipschitz\n Om = u.max() - u.min()\n mu = yrng.dirichlet(np.ones(k)); nu = yrng.dirichlet(np.ones(k))\n lhs = w1(tilt(mu, u), tilt(nu, u), Dm); rhs = np.exp(Om) * (1 + 2 * Delta * ell) * w1(mu, nu, Dm)\n ok(lhs <= rhs + 1e-9, "tilt by a common weight")\n up = u + yrng.uniform(-1, 1, size=k) * float(yrng.uniform(0, 0.5))\n eta = np.abs(up - u).max()\n ok(w1(tilt(mu, u), tilt(mu, up), Dm) <= 2 * Delta * eta + 1e-9, "two tilts of one measure")\nok(48 * 2 == 96 and 2 * 48 * 48 == 96 * 48, "constants of the perturbation proposition")\n\n# (z) gauge-invariant perturbations and the small-field bound\ndef zq(rng, scale):\n g = [1.0] + [rng.gauss(0, scale) for _ in range(3)] if scale < 1 else [rng.gauss(0, 1) for _ in range(4)]\n r = math.sqrt(sum(v * v for v in g)); return tuple(v / r for v in g)\ndef holo(cfg, z, steps):\n h, p = ONE, z\n for d, s in steps:\n if s == 1:\n h = qm(h, cfg((p, d))); p = move(p, d)\n else:\n p = move(p, d, -1); h = qm(h, qc(cfg((p, d))))\n return h\nzr = random.Random(2910)\nfor n in (2,):\n V = [(x, mu) for x in product(range(n), repeat=4) for mu in range(4) if active((x, mu))]\n Vset = set(V)\n zz, ww = zq(zr, 2), zq(zr, 2)\n WZ = {tuple(int(c) for c in s) for s in "0010 0011 0100 0110 1001 1011 1100 1101".split()}\n gfun = lambda x: ww if res(x) in WZ else zz\n QV = {e: zq(zr, 2) for e in V}\n A = lambda l: QV.get(l, ONE)\n def B(l):\n x, mu = l\n return qm(qm(gfun(x), A(l)), qc(gfun(move(x, mu))))\n win = list(product(range(-2, n + 2), repeat=4))\n for x in win:\n for mu in range(4):\n l = (x, mu)\n if not active(l):\n ok(abs(B(l)[0] - 1) < 1e-12, "Q^g is 1 on F")\n def wsum(cfg):\n tot = 0.0\n for x in win:\n for a in range(4):\n for b in range(4):\n if a != b:\n tot += holo(cfg, x, [(a, 1), (a, 1), (b, 1), (a, -1), (a, -1), (b, -1)])[0]\n return tot\n ok(abs(wsum(A) - wsum(B)) < 1e-8, "gauge-invariant weight unchanged")\nfor n in (2, 4):\n m = n // 2\n V = [(x, mu) for x in product(range(n), repeat=4) for mu in range(4) if active((x, mu))]\n for trial in range(4):\n sc = [0.3, 0.1, 0.03, 0.01][trial]\n QV = {e: zq(zr, sc) for e in V}\n cfg = lambda l: QV.get(l, ONE)\n eta = 0.0\n for x in product(range(-1, n + 1), repeat=4):\n for a, b in combinations(range(4), 2):\n eta = max(eta, chord(holo(cfg, x, [(a, 1), (b, 1), (a, -1), (b, -1)])))\n mean = sum(chord(QV[e]) for e in V) / len(V)\n ok(mean <= m * (m + 1) * eta + 1e-12, "small-field bound")\n\nprint(f"all {checks} checks passed")\n', 'd5/abelian_growth.py': '"""\nCheck of the obstruction mechanism: for an abelian field the composed cut-off\naverage multiplies a constant curvature by exactly 4 per step (Lemma torusstep\n/ Theorem torusscales), so a field with no fine defect above theta has every\nscale-j plaquette equal to 4^j theta.\n\nModel: U(1), two directions (the two directions of the plane of the curvature;\nin four dimensions the fields are taken independent of the two transverse\ncoordinates, the transverse tree links are trivial, and the sixteen paths of a\npair reduce to these four), periodic torus of side L=2^m, blocks of side 2,\ntree gauge (tree links = 0), cut-off average\n c_{y,mu} = p_0 + (chi/4) sum_x wrap(p_x - p_0), chi=1 for small angles,\nwith p_x the angle of the path of offset x. Coarse plaquette angles are gauge\ninvariant; the coarse field is put back in the tree gauge and the step repeated.\n\nChecks:\n (A) constant curvature theta=2 pi n/L^2: every scale-j plaquette angle is 4^j theta\n (mod 2 pi), j up to log2(L)-2.\n (B) random small field: coarse plaquette angle = mean over the four offsets of the\n fine square holonomies (the statement of Lemma torusstep), one step, to 1e-12.\n"""\nimport numpy as np\n\ndef wrap(a):\n return (a + np.pi) % (2*np.pi) - np.pi\n\ndef plaq(th):\n # th[mu, x0, x1]; plaquette at x in plane (0,1): th0(x)+th1(x+e0)-th0(x+e1)-th1(x)\n t0, t1 = th\n return wrap(t0 + np.roll(t1, -1, axis=0) - np.roll(t0, -1, axis=1) - t1)\n\ndef tree_gauge(th):\n """Gauge transform so that the tree links of every block vanish:\n tree links of block y: (2y, dir 0) and (2y+o0 e0, dir 1), o0 in {0,1}.\n th\'_{x,mu} = th_{x,mu} + g(x) - g(x+e_mu)."""\n L = th.shape[1]\n g = np.zeros((L, L))\n t0, t1 = th\n for y0 in range(0, L, 2):\n for y1 in range(0, L, 2):\n g[y0, y1] = 0.0\n # link (2y,0): need t0[y0,y1] + g[y0,y1] - g[y0+1,y1] = 0\n g[y0+1, y1] = t0[y0, y1] + g[y0, y1]\n # links (2y+o0 e0, 1): t1[x] + g[x] - g[x+e1] = 0\n for o0 in (0, 1):\n g[y0+o0, y1+1] = t1[y0+o0, y1] + g[y0+o0, y1]\n new = np.empty_like(th)\n new[0] = wrap(t0 + g - np.roll(g, -1, axis=0))\n new[1] = wrap(t1 + g - np.roll(g, -1, axis=1))\n return new\n\ndef cutoff_average(th):\n """One step: returns coarse field c[mu, y0, y1] on the torus of side L/2."""\n L = th.shape[1]\n th = tree_gauge(th)\n t0, t1 = th\n assert np.allclose(t0[0::2, 0::2], 0, atol=1e-9) # tree links dir 0\n assert np.allclose(t1[:, 0::2], 0, atol=1e-9) # tree links dir 1\n c = np.zeros((2, L//2, L//2))\n for y0 in range(L//2):\n for y1 in range(L//2):\n # pair (y,0): paths through x = 2y+o, two links in direction 0\n paths = []\n for o0 in (0, 1):\n for o1 in (0, 1):\n x0, x1 = 2*y0+o0, 2*y1+o1\n paths.append(t0[x0 % L, x1 % L] + t0[(x0+1) % L, x1 % L])\n p0 = paths[0]\n dev = [wrap(p - p0) for p in paths]\n chi = 1.0 if max(abs(d) for d in dev) < 0.5 else 0.0 # cut-off (inactive here)\n c[0, y0, y1] = wrap(p0 + chi*np.mean(dev))\n paths = []\n for o0 in (0, 1):\n for o1 in (0, 1):\n x0, x1 = 2*y0+o0, 2*y1+o1\n paths.append(t1[x0 % L, x1 % L] + t1[x0 % L, (x1+1) % L])\n p0 = paths[0]\n dev = [wrap(p - p0) for p in paths]\n chi = 1.0 if max(abs(d) for d in dev) < 0.5 else 0.0\n c[1, y0, y1] = wrap(p0 + chi*np.mean(dev))\n return c\n\ndef square_means(th):\n """Mean over the four offsets of the holonomy of the fine square of side two at 2y+o."""\n P = plaq(th)\n L = th.shape[1]\n S = np.zeros((L//2, L//2))\n for y0 in range(L//2):\n for y1 in range(L//2):\n tot = 0.0\n for o0 in (0, 1):\n for o1 in (0, 1):\n x0, x1 = 2*y0+o0, 2*y1+o1\n tot += P[x0 % L, x1 % L] + P[(x0+1) % L, x1 % L] + P[x0 % L, (x1+1) % L] + P[(x0+1) % L, (x1+1) % L]\n S[y0, y1] = tot/4\n return S\n\nif __name__ == \'__main__\':\n rng = np.random.default_rng(1)\n # (A) constant curvature\n L, n = 256, 1\n theta = 2*np.pi*n/L**2\n th = np.zeros((2, L, L))\n th[1] = theta*np.arange(L)[:, None]*np.ones((1, L)) # th1(x) = theta x0\n th[0][L-1, :] = -theta*L*np.arange(L) # transition function on the seam column\n th = wrap(th)\n print(f"(A) L={L}, constant plaquette angle theta={theta:.6e}")\n cur = th\n j = 0\n while cur.shape[1] >= 4 and 8*4**j*theta < 0.5: # stop before the cut-off can activate\n P = plaq(cur)\n print(f" scale j={j}: side {cur.shape[1]:3d}, plaquette angle min={P.min():.6e} max={P.max():.6e}, 4^j theta={wrap(4**j*theta):.6e}")\n assert np.allclose(P, wrap(4**j*theta), atol=1e-10)\n cur = cutoff_average(cur)\n j += 1\n # (B) random small field, one step: coarse plaquette = mean of square holonomies\n L = 32\n th = rng.normal(scale=1e-3, size=(2, L, L))\n c = cutoff_average(th)\n Pc = plaq(c)\n S = square_means(th)\n err = np.abs(wrap(Pc - S)).max()\n print(f"(B) L={L}, random field with link angles ~1e-3: max |coarse plaquette - mean of four squares| = {err:.3e}")\n assert err < 1e-12\n print(" growth of the maximal plaquette angle in one step (random field):",\n f"{np.abs(plaq(th)).max():.3e} -> {np.abs(Pc).max():.3e}")\n print("all checks passed")\n', 'd5/bad_branch.py': '"""Scalar diagnostic and rational sign bound for BAD_BRANCHES.md."""\nfrom fractions import Fraction as F\nfrom math import sin,cos,sqrt\n\nleft=F(1,2);right=F(49,100)\n# Strict elementary bounds sin(1/4)<1/4, cos(1/4)>31/32,\n# 10.\nu=F(7,20)\nassert 2*F(7,5)*(u-u**3/6)>F(9,10)\nassert 2*F(10,7)*u==1 # sin(u)0\n\nsine_lower=F(1,4)-F(1,4)**3/6\nassert 2*F(7,5)*sine_lower>F(1,2)\nassert 2*F(3,2)*F(1,4)<1\n\ndef f(q):\n differences=[-.5-q]+[.49-q]*6\n m=max(2*sqrt(2)*abs(sin(d/2)) for d in differences)\n chi=max(0.,min(1.,2-2*m))\n return q+chi*sum(differences)/8\n\ngamma=f(0)\nfp=-.75+sqrt(2)*(3.5*sin(.25)-.61*cos(.25))\nprint(\'Rational proof: cutoff is in its transition branch at q=0\')\nprint(\'Rational strict upper bound for f\\\'(0): -91/3200 < 0\')\nprint(f\'Numerical f(0)={gamma:.12g}; f\\\'(0)={fp:.12g}\')\n# Locate the two additional scalar preimages; q=0 is the middle one.\ndef bisect(lo,hi):\n flo=f(lo)-gamma\n for _ in range(80):\n mid=(lo+hi)/2; fm=f(mid)-gamma\n if flo*fm<=0:hi=mid\n else:lo=mid;flo=fm\n return (lo+hi)/2\nroots=[bisect(-1,-1e-3),0.,bisect(1e-3,1)]\nfor q in roots:\n assert abs(f(q)-gamma)<1e-12\n print(f\'path angle q={q:.12g}, average angle f(q)={f(q):.12g}\')\nprint(\'Three path-link solutions for the same seven non-path links and average.\')\n', 'd5/basin.py': '"""Order-of-magnitude ledger for LARGE_FIELD.md (crude; see the note).\n\nBad set = links leaving a fixed geodesic ball of radius r1 in fibre gauge.\nSketch assumption: a bad link forces a plaquette with delta > rho = r1/4 in its block closure.\nRarity (RARE.md, torus): log q(rho) = -beta rho^2/16 + 6 log beta + 24.7 + log(6e*80).\nIsland + collar cost per block (ISLANDS.md 2): (4.5 beta C_G)^324.\nCoarse scales by chessboard alone: a coarse block of side 2^k with holonomy defect r1 forces\na fine plaquette > r1/4^(k+1) (Stokes over <= 4^(k+1) plaquettes); usable while the rarity\ncondition still holds at that threshold.\n"""\nfrom mpmath import mp, mpf, log, e\nmp.dps = 40\nCG = mpf(\'3e13\')\n\ndef island_ok(lb, rho):\n return -mp.e**lb*rho**2/16 + 6*lb + mpf(\'24.7\') + log(6*e*80) + 324*(log(mpf(\'4.5\'))+lb+log(CG)) + log(2) < 0\n\ndef beta_needed(rho):\n lo, hi = mpf(0), mpf(5000)\n for _ in range(300):\n mid = (lo+hi)/2\n lo, hi = (lo, mid) if island_ok(mid, rho) else (mid, hi)\n return mp.e**hi\n\nprint(\'basin radius r1 | plaquette level rho | beta for islands beaten by rarity\')\nfor r1 in [\'4.8e-18\', \'4.7e-16\', \'1e-8\', \'1e-4\', \'1e-2\', \'1e-1\']:\n r1 = mpf(r1); rho = r1/4\n print(f\'{mp.nstr(r1,3):>8} | {mp.nstr(rho,3):>8} | {mp.nstr(beta_needed(rho),3)}\')\n\nprint()\nprint(\'chessboard-only coarse scales k (coarse blocks of side 2^k) at which the island condition still holds\')\nfor r1, beta in [(\'4.8e-18\', \'1e38\'), (\'4.8e-18\', \'1e64\'), (\'1e-2\', \'1e8\'), (\'1e-2\', \'1e20\')]:\n r1 = mpf(r1); beta = mpf(beta); k = 0\n while island_ok(log(beta), r1/4**(k+1)):\n k += 1\n print(f\'r1={mp.nstr(r1,3)} beta={mp.nstr(beta,3)}: scales k = 0..{k-1} usable ({k} scales)\')\n', 'd5/bootstrap.py': '"""Window bootstrap for CALM_LINK.md section 3 (order of magnitude, SU(2)).\n\nWindow: cube of side 2R+1 blocks around the link j; m = (2R+1)^4 blocks.\n |L1| <= 81 m free links, n_P <= 576 m plaquettes (ISLANDS.md section 1).\nBoundary links of the window: N_d(R) <= 8 (2R+1)^3 * 81.\nResponse of a window expectation to one boundary link at distance R:\n C e^{-alpha_G R}, C = max(C_*, C_b) = 9.2e13 (OpenGluon CALM_DATA.md).\nBootstrap (ANNEALED.md Lemma 3) at rate m\' = alpha_G/2:\n N_d(R) C e^{-alpha_G R/2} <= 1/2.\nFloor of the bootstrap: 2 eta, eta = lam |L1| (eps_loc + p_nc) (osc factors O(1) for local G).\n (i) eps_loc small: lam |L1| eps_loc <= 1e-3, lam = beta/4, K = 4.8e-18 (as in islands.py).\n (ii) p_nc from torus chessboard rarity (RARE.md): p_nc <= n_P q(rho_c), rho_c = K/(8 n_P).\n (iii) p_nc from the density bound localcalm (any exterior, but only a fraction of positions):\n fraction 4096 m eps, eps >= 32 (6 log beta + 31)/(beta rho^2), rho = K/(3072 m).\n"""\nfrom mpmath import mp, mpf, log, exp, e\nmp.dps = 40\naG = mpf(\'2.5e-4\'); C = mpf(\'9.2e13\'); K = mpf(\'4.8e-18\')\n\ndef bisect(f, lo, hi, n=300):\n # smallest x in [lo,hi] with f(x) <= 0, f decreasing\n for _ in range(n):\n mid = (lo+hi)/2\n lo, hi = (mid, hi) if f(mid) > 0 else (lo, mid)\n return hi\n\nR = bisect(lambda R: log(8*(2*R+1)**3*81*C) - aG*R/2 - log(mpf(1)/2), mpf(1), mpf(1e8))\nR = mp.ceil(R)\nm = (2*R+1)**4; L1 = 81*m; nP = 576*m\nprint(f\'bootstrap radius R = {mp.nstr(R,4)} blocks; window m = {mp.nstr(m,3)} blocks, |L1| <= {mp.nstr(L1,3)}\')\nprint(f\' contraction factor at R: {mp.nstr(8*(2*R+1)**3*81*C*exp(-aG*R/2),4)}\')\n\n# (i) eps_loc\nA = 73*m*log(mpf(\'3e8\')*nP**mpf(\'1.5\')/K**3)\nlb = bisect(lambda lb: A + log(exp(lb)/4*L1*1000) - mpf(3)/4*exp(lb)/4*K**2, mpf(1), mpf(2000))\nprint(f\'(i) lam|L1|eps_loc <= 1e-3 needs beta >= {mp.nstr(exp(lb),3)}\')\n\n# (ii) torus rarity\nrc = K/(8*nP)\nlogq = lambda lb: -exp(lb)*rc**2/16 + 6*lb + mpf(\'24.7\') + log(6*e*80)\nlb2 = bisect(lambda lb: lb - log(4) + log(L1) + log(nP) + logq(lb) - log(mpf(\'1e-3\')), mpf(1), mpf(2000))\nprint(f\'(ii) torus: lam|L1| n_P q(rho_c) <= 1e-3 needs beta >= {mp.nstr(exp(lb2),3)} (rho_c = {mp.nstr(rc,3)})\')\n\n# (iii) density bound: lam |L1| * 4096 m eps, with the smallest admissible eps\nrho = K/(3072*m)\ndef dens(beta):\n eps = 32*(6*log(beta)+31)/(beta*rho**2)\n return beta/4*L1*4096*m*eps\nfor beta in [mpf(\'1e10\'), mpf(\'1e100\'), mpf(\'1e1000\')]:\n print(f\'(iii) density bound: lam|L1| p_nc >= {mp.nstr(dens(beta),3)} at beta = {mp.nstr(beta,3)}\')\nprint(\' (beta-independent up to log beta: the density bound can never make the floor small)\')\n', 'd5/branch_controls.py': '"""Batched SU(2) constraint Jacobians near path folds and hard-label boundaries.\n\nComputation only. Small controls selected away from label boundaries need\nnot span even though all eight private links give a regular submersion.\nNo Wasserstein bound or divergent integrated response is inferred.\n"""\nimport argparse\nimport os\np=argparse.ArgumentParser();p.add_argument(\'--device\',choices=[\'cpu\',\'gpu\'],required=True)\np.add_argument(\'--batch\',type=int,default=64);p.add_argument(\'--batches\',type=int,default=1)\np.add_argument(\'--seed\',type=int,default=20261103);p.add_argument(\'--reference\',action=\'store_true\')\nargs=p.parse_args()\nos.environ[\'JAX_PLATFORMS\']=\'cpu\' if args.device==\'cpu\' else \'cuda\'\nos.environ[\'XLA_PYTHON_CLIENT_PREALLOCATE\']=\'false\'\nimport json\nimport math\nimport time\nfrom pathlib import Path\nimport numpy as np\nimport jax\njax.config.update(\'jax_enable_x64\',True)\nimport jax.numpy as j\nSQ2=math.sqrt(2)\n\ndef mul(a,b):\n return j.concatenate(((a[...,0]*b[...,0]-j.sum(a[...,1:]*b[...,1:],axis=-1))[...,None],\n a[...,0,None]*b[...,1:]+b[...,0,None]*a[...,1:]+j.cross(a[...,1:],b[...,1:])),axis=-1)\ndef inv(q):return q*j.array([1.,-1.,-1.,-1.])\ndef qexp(z):\n t=j.sum(z*z,axis=-1)/2;r=j.sqrt(j.maximum(t,1e-30))\n c=j.where(t<1e-12,1-t/2+t*t/24,j.cos(r))\n s=j.where(t<1e-12,1-t/6+t*t/120,j.sin(r)/r)/SQ2\n return j.concatenate((c[...,None],s[...,None]*z),axis=-1)\ndef qlog(q):\n v=q[...,1:];s2=j.sum(v*v,axis=-1);s=j.sqrt(j.maximum(s2,1e-30))\n ratio=j.where(s2<1e-16,SQ2/(j.where(j.abs(q[...,0])>1e-12,q[...,0],1.)),SQ2*j.arctan2(s,q[...,0])/s)\n return ratio[...,None]*v\n\ndef value(ell,u,w):\n paths=j.concatenate((mul(u,ell[1:]),mul(ell[1:],w)),axis=0)\n relative=mul(inv(ell[0]),paths)\n distances=j.sqrt(j.maximum(2*j.sum((relative-j.array([1.,0.,0.,0.]))**2,axis=-1),1e-30))\n ordered=j.sort(distances)\n m=ordered[-1];chi=j.clip(2-2*m,0.,1.)\n N=j.sum(qlog(relative),axis=0)/16\n return mul(ell[0],qexp(chi*N)),m,ordered[-1]-ordered[-2]\n\ndef jacobian(ell,u,w):\n def shifted(delta):return value(mul(ell,qexp(delta)),u,w)[0]\n q,m,gap=value(ell,u,w)\n raw=jax.jacfwd(shifted)(j.zeros((8,3))).reshape(4,24)\n # Right-trivialise dq: sqrt(2)*vector(q^-1 dq).\n basis=j.eye(4)\n tangent=SQ2*jax.vmap(lambda v:mul(inv(q),v)[1:])(basis).T\n return tangent@raw,q,m,gap\n\n@jax.jit\ndef batch_diagnostic(ells,us,ws,radii):\n J,c,m,gap=jax.vmap(jacobian)(ells,us,ws)\n relative=mul(inv(c)[:,None,:],ells[:,1:,:])\n distance=j.linalg.norm(qlog(relative),axis=-1)\n clearance=j.abs(distance-radii[:,None])\n eligible=clearance>radii[:,None]*.05\n mask=j.concatenate((j.ones((ells.shape[0],1),dtype=bool),eligible),axis=1)\n allowed=J*j.repeat(mask,3,axis=1)[:,None,:]\n full=j.linalg.svd(J,compute_uv=False)[:,-1]\n path=j.linalg.svd(J[:,:,:3],compute_uv=False)[:,-1]\n interior=j.linalg.svd(allowed,compute_uv=False)[:,-1]\n return j.stack((full,path,interior,m,gap,j.sum(eligible,axis=1)),axis=1),J,c\n\ndef nmul(a,b):\n return np.r_[a[0]*b[0]-a[1:]@b[1:],a[0]*b[1:]+b[0]*a[1:]+np.cross(a[1:],b[1:])]\ndef ninv(q):return q*np.array([1.,-1.,-1.,-1.])\ndef nexp(z):\n s=np.linalg.norm(z)/SQ2\n return np.r_[math.cos(s),z*(math.sin(s)/(SQ2*s) if s else 1/SQ2)]\ndef nlog(q):\n s=np.linalg.norm(q[1:]);return q[1:]*(SQ2*math.atan2(s,q[0])/s if s else SQ2)\ndef nvalue(ell,u,w):\n paths=[nmul(ua,la) for ua,la in zip(u,ell[1:])]+[nmul(la,wa) for la,wa in zip(ell[1:],w)]\n rel=[nmul(ninv(ell[0]),pa) for pa in paths]\n m=max(np.linalg.norm(q-np.array([1.,0,0,0]))*SQ2 for q in rel)\n chi=max(0.,min(1.,2-2*m));N=sum((nlog(q) for q in rel),np.zeros(3))/16\n return nmul(ell[0],nexp(chi*N))\n\ndef generate(batch,seed,reference=False):\n rng=np.random.default_rng(seed)\n eps=np.exp(rng.uniform(np.log(.02 if reference else 1e-7),np.log(.2),batch))\n radius=np.exp(rng.uniform(np.log(1e-5),np.log(.02),batch))\n perturb=eps*np.exp(rng.uniform(np.log(.0001),np.log(.3),batch))\n ells=[];us=[];ws=[]\n for e,r,sigma in zip(eps,radius,perturb):\n a=.5;split=.001\n q=2*math.asin((1-e)/(2*SQ2))-a-split\n chi=2*e\n N=(1-7*chi/8)/(2*SQ2*math.cos((a+split+q)/2))\n b=(8*N+a+7*q)/6\n left=[-a-split]+[b]*6;right=[-a+split]+[b]*6\n P=[nexp(np.array([SQ2*t,0,0])+sigma*rng.normal(size=3)) for t in left]\n Pp=[nexp(np.array([SQ2*t,0,0])+sigma*rng.normal(size=3)) for t in right]\n path=nexp(np.array([SQ2*q,0,0]))\n # Compute the target average before reparameterising the other private links.\n temp=np.array([path]+[np.array([1.,0,0,0])]*7)\n c=nvalue(temp,np.array(P),np.array(Pp))\n priv=[]\n for k in range(7):\n direction=np.array([1.,0,0])+(.3 if k else .001)*rng.normal(size=3)\n direction/=np.linalg.norm(direction)\n distance=r if k==0 else max(20*r,.1)\n priv.append(nmul(c,nexp(distance*direction)))\n ell=np.array([path]+priv)\n u=np.array([nmul(pa,ninv(la)) for pa,la in zip(P,priv)])\n w=np.array([nmul(ninv(la),pa) for pa,la in zip(Pp,priv)])\n ells.append(ell);us.append(u);ws.append(w)\n return np.array(ells),np.array(us),np.array(ws),radius,eps,perturb\n\nstarted=time.monotonic()\ndevices=[str(x) for x in jax.devices()]\nif args.device==\'gpu\':assert all(x.platform==\'gpu\' for x in jax.devices())\nelse:assert all(x.platform==\'cpu\' for x in jax.devices())\nsummary={\'classification\':\'floating computation; not a transport theorem\',\'device\':args.device,\n \'devices\':devices,\'jax_version\':jax.__version__,\'numpy_version\':np.__version__,\n \'seed\':args.seed,\'batch\':args.batch,\'requested_batches\':args.batches,\'samples\':0,\'candidates\':[]}\ncompile_seconds=None;scan_seconds=0.;fd_error=None;full_min=1e99\nbins={}\nfor index in range(args.batches):\n host=generate(args.batch,args.seed+index,args.reference)\n ell,u,w,r,e,pert=host\n before=time.monotonic()\n result,J,c=batch_diagnostic(j.asarray(ell),j.asarray(u),j.asarray(w),j.asarray(r))\n result=np.array(result);J=np.array(J);c=np.array(c)\n duration=time.monotonic()-before\n if index==0:compile_seconds=duration\n else:scan_seconds+=duration\n assert np.isfinite(result).all() and np.isfinite(J).all()\n smooth=(result[:,4]>1e-8)&(np.abs(result[:,3]-1)>1e-8)&(np.abs(result[:,3]-.5)>1e-8)\n if smooth.any():\n full_min=min(full_min,float(result[smooth,0].min()))\n assert full_min>.0309,(\'full-submersion bound contradicted; stop and audit\',full_min)\n if args.reference and index==0:\n errs=[]\n for k in np.flatnonzero(smooth)[:8]:\n delta=np.random.default_rng(args.seed+int(k)).normal(size=(8,3))\n delta/=np.linalg.norm(delta);h=1e-6\n plus=np.array([nmul(la,nexp(h*z)) for la,z in zip(ell[k],delta)])\n minus=np.array([nmul(la,nexp(-h*z)) for la,z in zip(ell[k],delta)])\n raw=(nvalue(plus,u[k],w[k])-nvalue(minus,u[k],w[k]))/(2*h)\n fd=SQ2*nmul(ninv(c[k]),raw)[1:]\n errs.append(float(np.linalg.norm(fd-J[k]@delta.reshape(-1))))\n assert len(errs)>=4 and max(errs)<2e-6,errs\n fd_error=max(errs)\n for k in np.flatnonzero(smooth):\n key=str(int(math.floor(math.log10(e[k]))))\n row=bins.setdefault(key,{\'samples\':0,\'min_interior_sigma\':1e99,\'max_interior_sigma\':0.,\'min_full_sigma\':1e99})\n row[\'samples\']+=1;row[\'min_interior_sigma\']=min(row[\'min_interior_sigma\'],float(result[k,2]))\n row[\'max_interior_sigma\']=max(row[\'max_interior_sigma\'],float(result[k,2]))\n row[\'min_full_sigma\']=min(row[\'min_full_sigma\'],float(result[k,0]))\n # Retain bounded, reproducible candidates, not full device arrays.\n for k in np.argsort(result[:,2])[:2]:\n if not smooth[k]:continue\n summary[\'candidates\'].append({\'batch_index\':index,\'sample_index\':int(k),\'epsilon\':float(e[k]),\n \'radius\':float(r[k]),\'nonabelian_perturbation\':float(pert[k]),\'metrics\':result[k].tolist(),\n \'ell\':ell[k].tolist(),\'u\':u[k].tolist(),\'w\':w[k].tolist(),\'c\':c[k].tolist()})\n summary[\'candidates\']=sorted(summary[\'candidates\'],key=lambda x:x[\'metrics\'][2])[:8]\n summary[\'samples\']+=args.batch\n print(json.dumps({\'batch_index\':index,\'samples\':summary[\'samples\'],\'seconds\':duration,\n \'min_full_sigma\':full_min,\'min_interior_sigma\':min(x[\'metrics\'][2] for x in summary[\'candidates\'])}),flush=True)\n # Saturation: several independently seeded batches and all epsilon decades covered.\n if not args.reference and index>=7 and len(bins)>=6 and summary[\'candidates\'][0][\'metrics\'][2]<1e-6:\n summary[\'early_stop\']=\'candidate saturation after eight independent batches\';break\nsummary.update(compile_first_batch_seconds=compile_seconds,scan_seconds=scan_seconds,\n total_seconds=time.monotonic()-started,finite_difference_error=fd_error,\n min_full_sigma=full_min,epsilon_decades=bins)\nPath(\'result.json\').write_text(json.dumps(summary,indent=2,sort_keys=True)+\'\\n\')\nprint(json.dumps({k:v for k,v in summary.items() if k!=\'candidates\'},indent=2,sort_keys=True))\n', 'd5/chart_bounds.py': '"""Rational arithmetic certificate for CANONICAL_CHART.md constants.\n\nTaylor series use explicit positive tails. This checks scalar inequalities;\nit does not replace the analytic proof of the chart or its Hessian.\n"""\nfrom fractions import Fraction as F\n\n\ndef exp_upper(t, n=16):\n term = total = F(1)\n for k in range(1, n + 1):\n term *= t / k\n total += term\n nxt = term * t / (n + 1)\n return total + nxt / (1 - t / (n + 2))\n\n\ndef minus_log_upper(t, n=16):\n assert 0 <= t < 1\n total = sum((t**k / k for k in range(1, n + 1)), F(0))\n return total + t**(n + 1) / ((n + 1) * (1 - t))\n\nrho = F(1, 10000)\nR = 44 * rho\ns = exp_upper(46 * rho) - 1\ncontraction = F(7, 8) * (1 + s) / (1 - s)\nimage = F(7, 8) * minus_log_upper(s)\nerror = 14 * s / (1 - s)\nlogdet = 3 * minus_log_upper(error)\nassert contraction < F(9, 10)\nassert image < R\nassert error < F(7, 100)\nassert logdet < 1\nassert exp_upper(rho) - 1 < F(1, 100)\nfirst = R / (rho / 2)\nsecond = 2 * R / (rho / 2)**2\naccel = second + 2 * first**2\nassert first == 88 and second == 3520000 and accel < 4000000\nkappa = F(1, 10**10)\naccel_total = 2 + 2 * 4000000\nlower_Q = F(98, 100) * (F(1, 26) - 54000 * kappa) - 12 * kappa * accel_total\nupper_Q = (48 + 84 * kappa) * (1 + 2 * first**2) + 12 * kappa * accel_total\nassert lower_Q > F(1, 52)\nassert upper_Q < 800000\nlogdet_hess = 16 / rho**2\nassert logdet_hess == 1600000000\nlam = F(2 * 10**11)\nassert lam / 52 - logdet_hess >= lam / 104\nprint(\'Rational upper bounds (displayed as decimals; comparisons use Fractions):\')\nfor name, val in [(\'complex contraction\', contraction), (\'fixed-point image radius\', image),\n (\'normalised derivative error\', error), (\'logdet residual\', logdet),\n (\'path acceleration bound\', accel), (\'Q Hessian lower bound\', lower_Q),\n (\'Q Hessian absolute upper bound\', upper_Q)]:\n print(f\'{name}: {float(val):.12g}\')\nprint(\'Sum logdet Hessian absolute bound: 1600000000\')\nprint(\'lambda >= 200000000000 implies Hess V_eff >= lambda/104\')\nprint(\'All rational inequalities passed.\')\n\nalpha = F(1,10**14)\nneighbours = 45 * 7**4\nweighted_error = neighbours * 10**6 * (exp_upper(3*alpha)-1)\nassert weighted_error < F(1,208)\nassert upper_Q*lam+2400000000 < 10**6*lam\nassert 208*(1+2*88**2)<3300000\nprint(f\'Weighted Hessian error / lambda <= {float(weighted_error):.12g} < 1/208\')\nprint(\'Restricted-chart covariance amplitude <= 3300000/lambda, rate 1e-14\')\n', 'd5/chart_probe.py': '"""Nonabelian local-pair diagnostic for CANONICAL_CHART.md (not a certificate).\n\nFinite differences independently compare the physical path-link Jacobian\nwith H=I+N_X. Exponential coordinates use an HS-orthonormal SU(2) basis.\n"""\nimport numpy as np\nfrom math import sin, cos, atan2, sqrt\n\ndef mul(a,b):\n return np.r_[a[0]*b[0]-a[1:]@b[1:],a[0]*b[1:]+b[0]*a[1:]+np.cross(a[1:],b[1:])]\ndef inv(a): return np.r_[a[0],-a[1:]]\ndef exp(x):\n r=np.linalg.norm(x)/sqrt(2)\n return np.r_[cos(r), x*(sin(r)/(sqrt(2)*r) if r else 1/sqrt(2))]\ndef log(q):\n s=np.linalg.norm(q[1:])\n return q[1:]*(sqrt(2)*atan2(s,q[0])/s if s else sqrt(2))\n\ndef run(scale):\n rng=np.random.default_rng(20261103)\n c=exp(np.array([.3,-.2,.1]))\n # Pair mu=0: offset zero has tree u0=w0=I, and all other u,w are active.\n u=[exp(scale*rng.normal(size=3)) for _ in range(7)]\n w=[exp(scale*rng.normal(size=3)) for _ in range(7)]\n ell=[mul(c,exp(scale*rng.normal(size=3))) for _ in range(7)]\n A=[mul(inv(c),mul(ua,la)) for ua,la in zip(u,ell)]\n A += [mul(inv(c),mul(la,wa)) for la,wa in zip(ell,w)]\n def N(X): return sum((log(mul(exp(-X),a)) for a in A),np.zeros(3))/16\n X=np.zeros(3)\n for iteration in range(1000):\n new=-N(X)\n if np.linalg.norm(new-X)<1e-16: X=new;break\n X=new\n residual=np.linalg.norm(X+N(X))\n base=mul(c,exp(X))\n def coarse_from_path(path):\n Nx=sum((log(mul(inv(path),mul(c,a))) for a in A),np.zeros(3))/16\n return mul(path,exp(Nx))\n errors=[]\n for h in [1e-4,1e-5,1e-6]:\n H=np.eye(3);J=np.zeros((3,3))\n for j in range(3):\n e=np.eye(3)[j]*h\n H[:,j]+=(N(X+e)-N(X-e))/(2*h)\n plus=coarse_from_path(mul(base,exp(e)))\n minus=coarse_from_path(mul(base,exp(-e)))\n J[:,j]=(log(mul(inv(c),plus))-log(mul(inv(c),minus)))/(2*h)\n err=abs(np.linalg.det(J)/np.linalg.det(H)-1)\n errors.append(err)\n print(f\'scale={scale:g} step={h:g} detJ={np.linalg.det(J):.12g} detH={np.linalg.det(H):.12g} relerr={err:.3g}\')\n assert residual<1e-13 and min(errors)<1e-7\n print(f\' fixed-point residual={residual:.3g}, iterations={iteration+1}\')\n\nif __name__ == \'__main__\':\n for scale in [1e-3,1e-4,1e-5]:\n run(scale)\n print(\'Nonabelian determinant diagnostic passed (floating computation only).\')\n', 'd5/check_labelcov.py': '"""Certified arithmetic for the subsection ssec:labelcov (interval arithmetic, mpmath.iv).\nInputs from the paper (Theorem thm:islandwindow, Lemma lem:lambdatwo, Proposition\nprop:islandmass): alpha_G = 2.5e-4, rho = 2.17e-16, r = 43 rho, beta* (enclosures),\nlog10(M q*) (upper bounds), bar Lambda_2 = 99.0001 beta + 4.65e6,\nsigma(kappa) = sum_{y in Z^4} exp(-kappa |y|_inf) in closed form.\nEvery claimed inequality is checked on interval enclosures; a check passes only if it\nholds for the whole interval. All quantities are evaluated at beta = beta*, which\nbounds them for beta_W >= beta* by the monotonicity proved in Corollary\ncor:fibrecovnumbers (b_* <= (beta_W/beta*) b_*(beta*); b_* eps^{1/2}, b_* eps and g_R\ndecrease)."""\nfrom mpmath import iv\niv.dps = 50\nln10 = iv.log(10)\ndef log10(x): return iv.log(x)/ln10\ndef hi(x): return x.b\ndef lo(x): return x.a\nok = []\ndef check(name, cond):\n ok.append((name, bool(cond))); print(("PASS " if cond else "FAIL ") + name)\ndef show(name, x): print(f"{name} in [{float(lo(x)):.6g}, {float(hi(x)):.6g}]")\ndef sig(kap):\n x = iv.exp(-kap)\n return 1 + 64*x*(1+4*x+x**2)/(1-x)**4 + 16*x/(1-x)**2\n\naG = iv.mpf(\'2.5e-4\')\nrho = iv.mpf(\'2.17e-16\'); r = 43*rho\ns2 = sig(2*aG); s1 = sig(aG)\nshow("sigma(2 alpha_G)", s2)\ncheck("sigma(2 alpha_G) <= 6.145e15 (value in prop:islandmass)", hi(s2) <= 6.145e15)\nshow("sigma(alpha_G)", s1)\ncheck("sigma(alpha_G) <= 9.831e16", hi(s1) <= 9.831e16)\ncheck("11^4 = 14641", 11**4 == 14641)\n\ndata = {1: dict(beta=iv.mpf([\'1.12205e37\',\'1.12207e37\']), L10e=iv.mpf(\'-14102.4\')),\n 5: dict(beta=iv.mpf([\'1.32162e37\',\'1.32164e37\']), L10e=iv.mpf(\'-16652.7\'))}\nout = {}\nfor s, D in data.items():\n print(f"\\n=== s = {s} ===")\n beta = D[\'beta\']; L10e = D[\'L10e\']; lneps = L10e*ln10\n Lam = iv.mpf(\'99.0001\')*beta + iv.mpf(\'4.65e6\')\n bstar = 1920*Lam**2*r**2/beta\n nu = 45*(2*s+9)**4\n bn = bstar*nu\n show("b_*", bstar); print("nu_s =", nu); show("log10(b_* nu_s)", log10(bn))\n check(f"s={s}: beta* rho^2/16 > 8 (b_* eps^(1/2), b_* eps decrease)", lo(beta*rho**2/16) > 8)\n check(f"s={s}: 2 sqrt(eps) <= 1", hi(L10e) < -1)\n R = 2*s+9\n lam = -(iv.log(iv.sqrt(2)) + 4*iv.log(2*R+1) + lneps/4) # -ln g_R at R = 2s+9\n show("lambda = -ln g_R at R = 2s+9", lam)\n check(f"s={s}: g_(2s+9) <= 1/2", lo(lam) >= hi(iv.log(2)))\n # Phi_R at R = 2s+9: b nu sigma(alpha) eps^{1/2} e^{alpha(2s+8)}\n lPhi = log10(bn*s1) + L10e/2 + aG*(2*s+8)/ln10\n show("log10 Phi_(2s+9)", lPhi)\n\n # ---- Corollary (i): labels, R = 2s+9, t = R(ceil(d/(1e4 R)) + 2), d >= 6s+34\n check(f"s={s}: (6s+34)(1-1e-4) >= 6s+33 (d >= t+6)", lo((6*s+34)*(1-iv.mpf(\'1e-4\'))) >= 6*s+33)\n cL = log10(14641*bn) + 2*aG*(8*s+41)/ln10\n show("log10 c_s = log10(11^4 b nu e^{2a(8s+41)})", cL)\n fL = log10(iv.mpf(2)) + lPhi\n show("log10 2 Phi_R (relative floor)", fL)\n lamL = lam/(10**4*R)\n show("chain rate lambda/(1e4 R)", lamL)\n # d at which the main relative term reaches 1, with V = 1\n d0 = cL*ln10/(2*aG*(1-iv.mpf(\'1e-4\')))\n show("d where 10^{c_s} e^{-2a(1-1e-4)d} = 1", d0)\n out[s] = dict(bn=hi(log10(bn)), lamR=lo(lam/R), cL=hi(cL), fL=hi(fL), lamL=lo(lamL), d0=hi(d0))\n\n # ---- Corollary (ii): fibre, regime E, R = 2s+9, t = R ceil(d/(1e4 R)), d >= 2s+10\n C1 = iv.mpf(9)/2*bn*iv.exp(4*aG*(2*s+9))\n show("log10 C_1 = log10((9/2) b nu e^{4a(2s+9)})", log10(C1))\n check(f"s={s}: lambda/(1e4 R) >= 2 alpha_G", lo(lamL) >= hi(2*aG))\n bnlo = 1920*(iv.mpf(\'99.0001\')*lo(beta)+iv.mpf(\'4.65e6\'))**2*r**2/lo(beta)*nu\n check(f"s={s}: 10 <= (9/4) b nu", lo(iv.mpf(9)/4*bnlo) >= 10)\n check(f"s={s}: (2s+10)(1-1e-4) > 2s+9 (t < d)", lo((2*s+10)*(1-iv.mpf(\'1e-4\'))) > 2*s+9)\n aF = log10(iv.mpf(17)/4*bn*s1) + L10e + aG*(2*s+8)/ln10\n show("log10 (17/4) eps^{1/2} Phi_R (fibre floor)", aF)\n out[s].update(C1=hi(log10(C1)), aF=hi(aF))\n\n # ---- Corollary (iii): fibre, regime S, R = ceil(2000 sqrt d), t = floor(d/2), 1e8 <= d <= 1e100\n Rmax = 2000*iv.mpf(10)**50 + 1\n lamS = -(iv.log(iv.sqrt(2)) + 4*iv.log(2*Rmax+1) + lneps/4)\n show("-ln g_R at R_max", lamS)\n check(f"s={s}: g(R_max) <= 1/2", lo(lamS) >= hi(iv.log(2)))\n check(f"s={s}: lambda_S/8002 > 1/2", lo(lamS/8002) > 0.5)\n dS = iv.mpf(\'1e8\')\n chainS = log10(iv.mpf(10)) - (lamS/8002 - iv.mpf(1)/2)*iv.sqrt(dS)/ln10\n mainS = log10(iv.mpf(9)/4*bn) + (2*aG*(2*s+9) - (aG*iv.sqrt(dS) - iv.mpf(1)/2)*iv.sqrt(dS))/ln10\n farS = log10(iv.mpf(17)/4*bn*s1) + L10e + aG*(4*s+17)/ln10\n show("log10 chain/e^{-sqrt d/2} at d=1e8", chainS)\n show("log10 main/e^{-sqrt d/2} at d=1e8", mainS)\n show("log10 far coefficient", farS)\n tot = iv.mpf(10)**hi(chainS) + iv.mpf(10)**hi(mainS) + iv.mpf(10)**hi(farS)\n show("log10 C_S", log10(tot))\n out[s].update(CS=hi(log10(tot)), chainS=hi(chainS))\n\nprint("\\n=== regime S, d-independent conditions ===")\ndS = iv.mpf(\'1e8\')\ncheck("d=1e8: d/2 - 1 >= 2000 sqrt d + 1 (t >= R)", lo(dS/2 - 1 - 2000*iv.sqrt(dS) - 1) >= 0)\ncheck("d=1e8: d/2 >= sqrt d + 4001 (floor(t/R) >= sqrt d/8002)", lo(dS/2 - iv.sqrt(dS) - 4001) >= 0)\ncheck("d=1e8: alpha_G > 1/(4 sqrt d) (main ratio decreases)", lo(aG - 1/(4*iv.sqrt(dS))) > 0)\nimport math\ncheck("d<=1e100: ceil(2000 sqrt d) <= 2000*10^50 + 1 = R_max (exact integers)", math.isqrt(10**100) == 10**50)\n\nprint("\\n=== stated numbers ===")\ncheck("s=1: log10(b_* nu) <= 22.084", out[1][\'bn\'] <= 22.084)\ncheck("s=5: log10(b_* nu) <= 23.104", out[5][\'bn\'] <= 23.104)\ncheck("s=1: -ln g per block >= 736", out[1][\'lamR\'] >= 736)\ncheck("s=5: -ln g per block >= 503", out[5][\'lamR\'] >= 503)\ncheck("s=1: c_1 <= 26.26", out[1][\'cL\'] <= 26.26)\ncheck("s=5: c_5 <= 27.29", out[5][\'cL\'] <= 27.29)\ncheck("s=1: 2 Phi_R <= 10^-7011.8", out[1][\'fL\'] <= -7011.8)\ncheck("s=5: 2 Phi_R <= 10^-8285.9", out[5]["fL"] <= -8285.9)\ncheck("s=1: lambda_1 >= 0.0736", out[1][\'lamL\'] >= 0.0736)\ncheck("s=5: lambda_5 >= 0.0503", out[5][\'lamL\'] >= 0.0503)\ncheck("s=1: d_0 <= 1.21e5", out[1][\'d0\'] <= 1.21e5)\ncheck("s=5: d_0 <= 1.26e5", out[5][\'d0\'] <= 1.26e5)\ncheck("s=1: a_1 >= log10 C_1 (22.75)", out[1][\'C1\'] <= 22.75)\ncheck("s=5: a_5 >= log10 C_1 (23.77)", out[5][\'C1\'] <= 23.77)\ncheck("s=1: fibre floor <= 10^-14062.6", out[1][\'aF\'] <= -14062.6)\ncheck("s=5: fibre floor <= 10^-16611.8", out[5][\'aF\'] <= -16611.8)\ncheck("s=1: C_S <= 10^-1965", out[1][\'CS\'] <= -1965)\ncheck("s=5: C_S <= 10^-2761", out[5][\'CS\'] <= -2761)\nprint("\\nALL PASS" if all(v for _, v in ok) else "\\nSOME FAIL")\n', 'd5/clusters.py': '"""Constants of the block bigwindow.tex (clusters of islands).\n\nInterval arithmetic (mpmath.iv, 60 digits). A claim "X <= c" is accepted\nonly when the upper end of the interval enclosing X is <= c. Large and small\nnumbers are handled through their logarithms. The data are those of\nTheorem thm:islandwindow: rho = 2.17e-16, r = 43 rho, H = 6^4, M = 11^4,\nalpha_G = 2.5e-4, beta_W = beta*.\n"""\nfrom mpmath import iv, mp\n\niv.dps = 60\nmp.dps = 60\n\nH, Mbox = 1296, 14641\nN5 = 11 ** 4 - 1 # neighbours at distance <= 5\nalphaG = iv.mpf(1) / 4000\nrho = iv.mpf(217) / iv.mpf(10) ** 18\nr = 43 * rho\nC0 = iv.mpf(1) / 2 + iv.mpf(2) / 3 * iv.log(24 * iv.pi ** 3)\nLN10 = iv.log(10)\ndef log10(x): return iv.log(x) / LN10\ndef up(x): return mp.nstr(mp.mpf(x._mpi_[1]), 12)\ndef lo(x): return mp.nstr(mp.mpf(x._mpi_[0]), 12)\n\nchecks = []\ndef check(name, ok):\n checks.append((name, bool(ok)))\n print(("PASS " if ok else "FAIL ") + name)\n\ndef sigma(k):\n x = iv.exp(-k)\n return 1 + 64 * x * (1 + 4 * x + x * x) / (1 - x) ** 4 + 16 * x / (1 - x) ** 2\n\n# M_1 = 10^(10^1700): ln M_1 = 10^1700 ln 10\nlnM1 = iv.mpf(10) ** 1700 * LN10\nm0 = 10 ** 5\n\nfor s in (1, 5):\n print("\\n================ s =", s, "================")\n Ns = (4 * s + 17) ** 4 - 1\n logq = -(H * (iv.log(2) + 2 * iv.log(Ns)) + 1 + iv.log(Mbox * H))\n def gpt(b):\n b = mp.mpf(b); rh = mp.mpf(217) / mp.mpf(10) ** 18\n c0 = mp.mpf(1) / 2 + mp.mpf(2) / 3 * mp.log(24 * mp.pi ** 3)\n lq = -(H * (mp.log(2) + 2 * mp.log(Ns)) + 1 + mp.log(Mbox * H))\n return 6 * (mp.log(b) + c0) - b * rh ** 2 / 16 - lq\n a, b = mp.mpf(96) / (mp.mpf(217) / mp.mpf(10) ** 18) ** 2, mp.mpf(10) ** 40\n for _ in range(400):\n m = (a + b) / 2\n if gpt(m) > 0: a = m\n else: b = m\n blo = iv.mpf(a * (1 - mp.mpf(10) ** -20)); bhi = iv.mpf(b * (1 + mp.mpf(10) ** -20))\n g = lambda be: 6 * (iv.log(be) + C0) - be * rho ** 2 / 16 - logq\n check("s=%d: root bracket beta* in [%s, %s]" % (s, lo(blo), up(bhi)),\n g(blo).a > 0 and g(bhi).b < 0)\n # monotonicity in beta: beta* rho^2/16 >= 32481 (s=1) / 38354 (s=5)\n slope = blo * rho ** 2 / 16\n print("beta* rho^2/16 >=", lo(slope))\n check("s=%d: beta* rho^2/16 >= %d" % (s, {1: 32481, 5: 38354}[s]),\n slope.a >= {1: 32481, 5: 38354}[s])\n l10Mq = log10(iv.mpf(Mbox)) + logq / LN10\n l10A = log10(iv.e * Mbox * H) + logq / LN10\n print("log10 Mq* <=", up(l10Mq), " log10 A_* <=", up(l10A))\n for th, lab, R in ((iv.mpf(0), "0", 10 ** 7), (iv.mpf(1) / 2, "1/2", 2 * 10 ** 7)):\n kap = 2 * (1 - th) * alphaG\n print("--- vartheta =", lab, " kappa =", lo(kap), " R =", R)\n Lam = iv.mpf(\'99.0001\') * bhi + iv.mpf(\'4.65e6\')\n c1 = 1920 * Lam ** 2 * r ** 2 / bhi * 45 * (2 * s + 7) ** 4 * iv.exp(kap * (2 * s + 9))\n l10c1 = log10(c1)\n sk2 = sigma(kap / 2)\n l10tau = l10c1 - kap * R / 2 / LN10 + log10(sk2)\n print("log10 c_1(beta*) <=", up(l10c1), " sigma(kappa/2) <=", up(sk2))\n print("log10 tau <=", up(l10tau))\n target = {(1, "0"): -1047, (1, "1/2"): -1045, (5, "0"): -1045, (5, "1/2"): -1044}[(s, lab)]\n check("s=%d theta=%s R=%d: tau <= 1e%d" % (s, lab, R, target), l10tau.b <= target)\n # reach l_m = R + (6/kappa) ln m\n def ell(lnm): return R + 6 / kap * lnm\n lM1 = ell(lnM1)\n l10lM1 = log10(lM1)\n print("log10 l_{M_1} in [", lo(l10lM1), ",", up(l10lM1), "]")\n check("s=%d theta=%s: l_{M_1} <= 10^1705" % (s, lab), l10lM1.b <= 1705)\n # nu_l at l = 10^1705, an upper bound for every l <= l_{M_1}\n l10N = 4 * log10(2 * iv.mpf(10) ** 1705 + 1)\n l10NA = l10N + l10A / 2\n print("log10 (N_l A^{1/2}) at l=1e1705 <=", up(l10NA))\n nu = 4 * (N5 + iv.mpf(10) ** l10NA) * iv.mpf(10) ** (l10A / (2 * H))\n l10nu = log10(nu)\n print("nu <=", up(nu), " log10 nu <=", up(l10nu))\n nub = {1: 0.2130, 5: 0.0222}[s]\n check("s=%d theta=%s: nu_l <= %s for l <= l_{M_1}" % (s, lab, nub), nu.b <= nub)\n # (ii): |Lambda| A^{(H+1)/2H} nu^{M_1}/(1-nu) <= |Lambda| 10^{-c M_1}\n pref = (H + 1) / iv.mpf(2 * H) * l10A - log10(1 - nu)\n print("log10 prefactor A^{(H+1)/2H}/(1-nu) <=", up(pref))\n cM = {1: -0.67, 5: -1.65}[s]\n check("s=%d theta=%s: global bound <= |Lambda| 10^{%s M_1}" % (s, lab, cM),\n pref.b <= 0 and l10nu.b <= cM)\n # (iii): m_0 = 1e5\n lm0 = ell(iv.log(m0))\n near = 4 * log10(2 * (m0 - 1) * lm0 + 1) + 4 * log10(2 * lm0 + 1) + 2 * l10Mq\n tail = pref + m0 * l10nu\n print("l_{m0} <=", up(lm0), " log10 near <=", up(near), " log10 tail <=", up(tail))\n tot = log10(iv.mpf(10) ** near + iv.mpf(10) ** tail)\n print("log10 (near + tail) <=", up(tot))\n tgt = {(1, "0"): -28126, (1, "1/2"): -28124, (5, "0"): -33227, (5, "1/2"): -33224}[(s, lab)]\n check("s=%d theta=%s: P(y bad, U(y) not an island) <= 1e%d + global" % (s, lab, tgt),\n tot.b <= tgt)\n check("s=%d theta=%s: same with the factor 1+1e-6 (beta_W > beta*)" % (s, lab),\n (tot + log10(1 + iv.mpf(10) ** -6)).b <= tgt)\n # beta_W > beta*: (1+1e-7+4e-4 log t)^8 t^12 e^{-64962(t-1)} <= 1+1e-6 for t >= 1\n # (value at t=1 is (1+1e-7)^8; log-derivative 3.2e-3/t + 12/t - 64962 < 0)\n v1 = (1 + iv.mpf(10) ** -7) ** 8\n check("s=%d: (1+1e-7)^8 <= 1+1e-6" % s, v1.b <= 1 + 1e-6)\n # slack of the stated near terms against a factor 1+1e-6 is checked below via the totals\n # where the counting stops (theta = 0 reach does not matter here)\n # nu_l >= 1 iff N_l >= A^{-1/2}(A^{-1/2H}/4 - N5)\n l10crit = -l10A / 2 + log10(iv.mpf(10) ** (-l10A / (2 * H)) / 4 - N5)\n l10lc = (l10crit) / 4 - log10(iv.mpf(2))\n print("nu_l = 1 at log10 l about", lo(l10lc), up(l10lc))\n l10l1 = (-l10A) / 4 - log10(iv.mpf(2))\n print("N_l A_* = 1 at log10 l about", lo(l10l1), up(l10l1))\n def nu_at(l10l):\n l10Nl = log10((2 * iv.mpf(10) ** l10l + 1) ** 4 - 1)\n return 4 * (N5 + iv.mpf(10) ** (l10Nl + l10A / 2)) * iv.mpf(10) ** (l10A / (2 * H))\n if s == 1:\n n1, n2 = nu_at(iv.mpf(\'1763.2\')), nu_at(iv.mpf(\'1763.3\'))\n print("nu at log10 l = 1763.2 <=", up(n1), "; at 1763.3 >=", lo(n2))\n check("s=1: nu_l < 1 at log10 l = 1763.2 (A = eMHq*)", n1.b < 1)\n check("s=1: nu_l > 1 at log10 l = 1763.3 (A = eMHq*)", n2.a > 1)\n # N_l A_* at log10 l = 3524.5, with A_* the enclosure\'s upper end replaced by its value\n l10NA = log10((2 * iv.mpf(10) ** iv.mpf(\'3524.5\') + 1) ** 4 - 1) + l10A\n print("log10 N_l A_* at log10 l = 3524.5 in", lo(l10NA), up(l10NA))\n check("s=1: N_l A_* >= 1 at log10 l = 3524.5", l10NA.a >= 0)\n\nprint("\\nall checks passed:", all(ok for _, ok in checks), "(%d checks)" % len(checks))\n', 'd5/composed_threshold.py': '"""\nComposed island threshold at scale j (SU(2), Wilson measure on the torus).\n\nInputs are the constants of main.tex:\n C_0 = 1/2 + (2/3) log(24 pi^3) (Lemma wilsonZ)\n q_rho(beta) = exp(6(log beta + C_0) - beta rho^2/16) (Theorem defects)\n eta_j <= 1.023 * 4^j * eta_0, eta_0 = 1.01 rho_0 (Theorem defectscales(iv), text after it)\n spreading 3(a_j - a) (Theorem defectscales(ii))\n witness box at the block scale: corners in 2y+[-5,5]^4 (proof of Theorem islandthreshold)\n Delta = (4s+3)^4 - 1, log q* = -H(log 2 + 2 log Delta) - log(e M H)\n\nOutput: beta*_j for the composed labels at scale j (blocks of side 2^{j+1} a),\nwith M_j, H_j computed below, and the comparison with k_* of Corollary defectscales.\n"""\nfrom mpmath import mp, mpf, log, exp, e, pi, findroot, floor\nmp.dps = 40\n\nC0 = mpf(1)/2 + mpf(2)/3*log(24*pi**3)\nC1 = C0 + log(12800)/6\n\ndef witness_counts(j):\n """M_j = number of fine unit cubes that can hold the fine witness of a bad\n scale-j block, H_j = max number of scale-j blocks whose witness set contains\n a given fine cube. Derivation: Lemma scalewitness."""\n if j == 0:\n return 11**4, 6**4\n side = 17*2**j - 4 # corners x - 2^{j+1} y in [-8 2^j + 2, 9 2^j - 3]\n lo, hi = -8*2**j + 2, 9*2**j - 3\n # number of integers y_c with 2^{j+1} y_c in [x_c - hi, x_c - lo]: brute force over x_c\n step = 2**(j+1)\n hmax = 0\n for xc in range(step):\n cnt = sum(1 for yc in range(-20, 21) if xc - hi <= step*yc <= xc - lo)\n hmax = max(hmax, cnt)\n return side**4, hmax**4\n\ndef logqstar(M, H, s):\n Delta = (4*s+3)**4 - 1\n return -H*(log(2) + 2*log(Delta)) - log(e*M*H)\n\ndef beta_star(rho0, lq):\n f = lambda b: 6*(log(b) + C0) - b*rho0**2/16 - lq\n bmax = 96/rho0**2\n assert f(bmax) > 0\n # bisection on [bmax, big]\n lo, hi = bmax, bmax\n while f(hi) > 0:\n hi *= 2\n for _ in range(200):\n mid = (lo+hi)/2\n if f(mid) > 0: lo = mid\n else: hi = mid\n return hi\n\ndef kstar(beta):\n """Corollary defectscales: largest k with 4^k * 1.01 rho_c <= 1e-4, rho_c^2 = 96(log beta + C_1)/beta."""\n rhoc = (96*(log(beta)+C1)/beta)**0.5\n k = 0\n while 4**(k+1)*mpf(\'1.01\')*rhoc <= mpf(\'1e-4\'):\n k += 1\n return k, rhoc\n\ndef composed(j, s, rho=mpf(\'1e-8\')):\n M, H = witness_counts(j)\n lq = logqstar(M, H, s)\n rho0 = rho/(mpf(\'1.01\')*mpf(\'1.023\')*4**j) if j >= 1 else rho\n b = beta_star(rho0, lq)\n return M, H, lq, rho0, b\n\nif __name__ == \'__main__\':\n print("check block scale (paper): s=1,5 at rho=1e-8")\n for s in (1,5):\n M,H,lq,rho0,b = composed(0,s)\n print(f" s={s}: M={M} H={H} log q*={float(lq):.1f} beta*={float(b):.4e}")\n print()\n for s in (5,1):\n print(f"s = {s}, rho = 1e-8 (label radii r=4.3e-7, eta=9.2e-7)")\n print(" j | side | M_j | H_j | |log q*_j| | rho_0 | beta*_j | 16^-j beta*_j | k_*(beta*_j) | k_*-j")\n for j in range(0, 13):\n M,H,lq,rho0,b = composed(j,s)\n k,_ = kstar(b)\n side = 11 if j==0 else 17*2**j-4\n print(f"{j:2d} | {side:6d} | {M:11d} | {H:4d} | {float(-lq):10.1f} | {float(rho0):.3e} | {float(b):.4e} | {float(b/16**j):.4e} | {k:3d} | {k-j:3d}")\n print()\n print("j_max(beta): largest j with beta >= beta*_j (s=5), and k_*(beta)")\n for ex in range(22, 44, 2):\n beta = mpf(10)**ex\n jm = -1\n for j in range(0, 30):\n if composed(j,5)[4] <= beta: jm = j\n else: break\n k,rhoc = kstar(beta)\n aj = 2**jm if jm>=0 else 0\n print(f" beta=1e{ex}: j_max={jm:2d} a_jmax/a={aj:8d} k_*={k:2d} a_k*/a={2**k:8d} ratio 2^(k_*-j_max)={2**(k-jm) if jm>=0 else \'n/a\'} (beta/2.9e22)^(1/4)={float((beta/mpf(\'2.9e22\'))**0.25):.3g}")\n', 'd5/constants.py': '"""Constants for D5.md (exact sums, mpmath for the window).\n\nN(2a) = sum over links e of Z^4 of exp(-2 a d(e, j)), d = l-infinity distance\nbetween link midpoints, j a fixed link. Links at midpoint distance in [k, k+1)\nare counted by shells of their base point; we use the upper bound obtained by\ngiving every link with base at l-inf distance k from base(j) the distance k-1\n(as in the proof of Theorem constrainedcube), so the result is an upper bound.\n"""\nfrom mpmath import mp, mpf, exp, log, sqrt\nmp.dps = 30\na = mpf(\'2.5e-4\')\n# links with base at l-inf distance k>=1: 4((2k+1)^4-(2k-1)^4) = 4(64k^3+16k)\ndef N(alpha):\n s = mpf(4) # k = 0: four links at the base of j, distance <= 1 -> weight <= 1\n k = 1\n while True:\n t = 4*(64*k**3+16*k)*exp(-alpha*(k-1))\n s += t\n if k > 10 and t < s*mpf(\'1e-25\'):\n break\n k += 1\n return s\nN2a = N(2*a)\nprint(\'N(2 alpha_G) <=\', mp.nstr(N2a, 6), \' sqrt =\', mp.nstr(sqrt(N2a), 6))\npbar = mpf(\'4.8\')\n# |d/dt E F| <= (120/lam) * (2 pbar sqrt(N)) * (pbar e^a sqrt(18) cQ lam)\nfor cQ in [mpf(4), mpf(8)]:\n C = 120*2*pbar*sqrt(N2a)*pbar*exp(a)*sqrt(18)*cQ\n print(\'c_Q =\', cQ, \' C_G <=\', mp.nstr(C, 4), \' n >= 17 C_G/alpha: 17C_G =\', mp.nstr(17*C, 4))\n# window: need lam*|V|*eps_W <= 1 with eps_W from Prop calmfibre, K = 4.8e-18\nK = mpf(\'4.8e-18\')\nfor alpha in [mpf(\'0.5\'), mpf(\'0.9\')]:\n C = 120*2*pbar*sqrt(N2a)*pbar*exp(a)*sqrt(18)*8\n n = 17*C/alpha\n W = (n/2)**4\n nP = 384*W\n V = 4*n**4\n # log eps_W = 45 W log(3e8 nP^1.5/K^3) - 3 lam K^2/4 ; require <= -log(lam V)\n L = 45*W*log(mpf(\'3e8\')*nP**mpf(\'1.5\')/K**3)\n lam = 4*(L + 400)/(3*K**2) # 400 >> log(lam V) here\n print(\'alpha =\', alpha, \' n ~\', mp.nstr(n, 3), \' |W| ~\', mp.nstr(W, 3),\n \' beta_W = 4 lam >~\', mp.nstr(4*lam, 3))\n # Prop calmrare(ii): calm exterior probability <= 7e-32 beta^1.5 |W|^-3\n print(\' P(calm exterior) <=\', mp.nstr(mpf(\'7e-32\')*(4*lam)**mpf(\'1.5\')/W**3, 3))\n', 'd5/coverage_checks.py': '"""Finite checks of the overlap constants; proof is in COARSE_LABELS.md."""\nfrom math import ceil\nfrom itertools import combinations, product\n\nfor radius, H1 in [(3,4),(5,6)]:\n worst=0\n for side in range(1,65):\n fine=2*side\n boxes=[{(2*y+j)%fine for j in range(-radius,radius+1)} for y in range(side)]\n for x in range(fine):\n count=sum(x in box for box in boxes)\n worst=max(worst,count)\n assert count<=H1\n print(f\'radius {radius}: one-coordinate overlap <= {H1}; attained {worst}\')\n print(f\' four-coordinate M={(2*radius+1)**4}, H={H1**4}\')\n\n# Exhaustive tiny incidence examples: the deterministic coverage inequality\n# is what permits the rare-event union bound. This does not test chessboard.\nfor labels in range(1,4):\n subsets=[set(i for i in range(3) if mask & (1<=k\nprint(\'Exhaustive tiny coverage implication: passed\')\n', 'd5/domain_probe.py': '"""Floating diagnostic of the proved asymptotic domain obstruction.\n\nThe proof is in LABEL_DOMAIN.md. These finite-scale values are not\ninterval certificates, and do not establish an explicit validity radius.\n"""\nimport numpy as np\nfrom scipy.optimize import root\nfrom chart_probe import mul, exp, log\n\ndef solve(z, initial):\n A=[exp(za) for za in z]\n def H(X):\n return X+sum((log(mul(exp(-X),a)) for a in A),np.zeros(3))/8\n out=root(H,initial,tol=1e-11)\n residual=np.linalg.norm(H(out.x))\n assert residual<1e-12\n return out.x,residual\n\nprint(\'Nonconvex physical-label pullback: floating diagnostic only\')\nfor radius in [.1,.03,.01,.003]:\n h=.02*radius\n a=radius+radius*h*h/6\n centre=np.tile(np.array([-a/7,0.,0.]),(7,1))\n v=np.zeros_like(centre);v[0,1]=1;v[1,1]=-1\n plus,rp=solve(centre+h*v,[a,0,0])\n minus,rm=solve(centre-h*v,[a,0,0])\n midpoint,r0=solve(centre,[a,0,0])\n free_max=max(np.linalg.norm(za) for za in centre+h*v)\n assert max(np.linalg.norm(plus),np.linalg.norm(minus))radius\n assert free_max= 0 (checked in A2) and the\n largest of the near paths for q <= -0.01 (checked in A1)."""\n if q.b <= mpf(\'-0.01\'):\n d = TH_NEAR - q + (t if t.a >= 0 else 0) # shifted path wins iff t > 0\n elif q.a >= 0:\n d = q - TH_FAR\n else:\n raise ValueError\n return q + chi_of(d) * (iv.mpf(\'4.88\') + t - 14 * q) / 16\n\n\ndef P(x, k=10):\n """print an interval endpoint or a real with k significant digits"""\n try:\n return f"{float(x):.{k}g}"\n except ValueError: # a proper interval: print its upper end\n return f"{float(x.b):.{k}g}"\n\n\ndef report(name, lo, hi):\n print(f"{name}: [{P(lo)}, {P(hi)}]")\n\n\n# ---------------------------------------------------------------- Part A1\nprint("Part A1: near the point g_L*, q in QL = [-0.0182, -0.0146], |t| <= 1e-3")\nQL = pieces(\'-0.0182\', \'-0.0146\', 400)\nT1 = X(\'-0.001\', \'0.001\')\nmn, mx = mpf(10), mpf(-10)\nfor q in QL:\n # the near paths are strictly farther from g than the far link,\n # for every value of the shift t in [-1e-3, 1e-3]\n m1 = (TH_NEAR - q + X(\'-0.001\', \'0\')) - (iv.mpf(\'0.5\') + q)\n assert m1.a > mpf(\'0.018\'), q\n mn = min(mn, m1.a)\nprint(" min over QL, t of (0.49 + min(t,0) - q) - (0.5 + q) >=", P(mn, 6))\nlo, hi = mpf(10), mpf(-10)\nfor q in QL:\n m = TWO_SQRT2 * iv.sin((TH_NEAR - q + T1) / 2)\n assert m.a > 0.5 and m.b < 1, q\n lo, hi = min(lo, m.a), max(hi, m.b)\nreport(" m on QL x T", lo, hi)\nlo = mpf(10)\nfor q in QL:\n br = iv.sin(TH_NEAR + T1 / 2 - q)\n assert br.a > mpf(\'0.47\'), q\n lo = min(lo, br.a)\nprint(" bracket sin(0.49 + t/2 - q) >=", P(lo, 6))\nlo = mpf(10)\nfor q in QL:\n dm = iv.sqrt(2) * iv.cos((TH_NEAR - q + T1) / 2)\n assert dm.a > mpf(\'1.3\'), q\n lo = min(lo, dm.a)\nprint(" d/ds of 2 sqrt2 sin((0.49 + s - q)/2) at s = 0 >=", P(lo, 6))\n\n# the torus equation near q_L, for t of both signs\nGAMMA_LO, GAMMA_HI = mpf(\'0.16978261\'), mpf(\'0.16978263\')\nfor tt in (X(\'-0.001\', \'0\'), X(\'0\', \'0.001\')):\n a = f_torus(iv.mpf(\'-0.0182\'), tt)\n b = f_torus(iv.mpf(\'-0.0146\'), tt)\n assert a.b < GAMMA_LO and b.a > GAMMA_HI\n # derivative of f in q: 1 + chi\'(q)(4.88+t-14q)/16 - 14 chi/16,\n # chi\' = 2 sqrt2 cos(d/2) (d = 0.49 + t_+ - q decreases in q)\n dlo, dhi = mpf(10), mpf(-10)\n for q in QL:\n d = TH_NEAR - q + (tt if tt.a >= 0 else 0)\n chi = chi_of(d)\n dchi = 2 * iv.sqrt(2) * iv.cos(d / 2)\n fp = 1 + dchi * (iv.mpf(\'4.88\') + tt - 14 * q) / 16 - 14 * chi / 16\n assert fp.a > mpf(\'1.3\')\n dlo, dhi = min(dlo, fp.a), max(dhi, fp.b)\n print(f" t in [{P(tt.a, 3)},{P(tt.b, 3)}]: f(-0.0182) < gamma*, "\n f"f(-0.0146) > gamma*, f\' in [{P(dlo, 5)}, {P(dhi, 5)}]")\n\n# ---------------------------------------------------------------- Part A2\nprint("Part A2: near the point g*, q in [0.05, 0.1], |t| <= 1e-3")\nQS = pieces(\'0.05\', \'0.1\', 400)\nmn = mpf(10)\nclo, chi_hi = mpf(10), mpf(-10)\nmlo, mhi = mpf(10), mpf(-10)\nc2 = mpf(-10)\nfor q in QS:\n marg = (q - TH_FAR) - (TH_NEAR - q + abs(T1))\n assert marg.a > mpf(\'0.1\'), q\n mn = min(mn, marg.a)\n m = TWO_SQRT2 * iv.sin((q - TH_FAR) / 2)\n assert m.a > 0.5 and m.b < 1\n mlo, mhi = min(mlo, m.a), max(mhi, m.b)\n ch = chi_of(q - TH_FAR)\n clo, chi_hi = min(clo, ch.a), max(chi_hi, ch.b)\n d2 = iv.sqrt(2) * iv.sin((q - TH_FAR) / 2) # chi_0\'\'\n c2 = max(c2, abs(d2).b)\nprint(" far margin (0.5 + q) - (0.49 + |t| - q) >=", P(mn, 6))\nreport(" m", mlo, mhi)\nreport(" chi_0", clo, chi_hi)\nprint(" |chi_0\'\'| <=", P(c2, 6), "; |t chi_0\'\'/16| <=", P(c2 * mpf(\'1e-3\') / 16, 4))\nfor q0 in (\'0.05\', \'0.1\'):\n v = f_torus(iv.mpf(q0), T1)\n assert v.a > GAMMA_HI + mpf(\'9e-4\')\n print(f" f({q0}, t) >= {P(v.a, 10)} > gamma* for |t| <= 1e-3")\nfor q0, sgn in ((\'0.0741\', -1), (\'0.0742\', 1)):\n q = iv.mpf(q0)\n d = q - TH_FAR\n fp = 1 - 14 * chi_of(d) / 16 + (-2 * iv.sqrt(2) * iv.cos(d / 2)) * (iv.mpf(\'4.88\') - 14 * q) / 16\n assert (fp.b < 0) if sgn < 0 else (fp.a > 0)\n print(f" f_0\'({q0}) in [{P(fp.a, 6)}, {P(fp.b, 6)}]")\n\n# ---------------------------------------------------------------- Part B\nprint("Part B: the Kantorovich gap")\ndist = TWO_SQRT2 * iv.sin(X(\'0.0897\', \'0.0914\') / 2)\nprint(" delta(g*, g_L*) >=", P(dist.a, 6))\nassert dist.a > mpf(\'0.1268\')\nprint(" 0.1268 - 2*0.0034 =", P(mpf(\'0.1268\') - 2 * mpf(\'0.0034\'), 6), ">= 0.12")\nprint(" geodesic length of t -> e^{it}: sqrt2 |t|; sqrt2 =", P(iv.sqrt(2).b, 8))\n\n# ---------------------------------------------------------------- Part C\nprint("Part C: constants of the chain law")\ns2 = iv.sqrt(2)\na1 = (1 + 6 * iv.mpf(\'1.1986\')) / s2\na2 = 6 * iv.mpf(\'0.5993\') / s2\nassert a1.b <= mpf(\'5.793\') and a2.b <= mpf(\'2.543\')\nprint(" (1 + 6*1.1986)/sqrt2 <=", P(a1.b, 8), "<= 5.793")\nprint(" 6*0.5993/sqrt2 <=", P(a2.b, 8), "<= 2.543")\nfor name, v in (("sqrt2*5.793", s2 * iv.mpf(\'5.793\')), ("sqrt2*64.94", s2 * iv.mpf(\'64.94\')),\n ("sqrt2*2.543", s2 * iv.mpf(\'2.543\')), ("sqrt2*32.47", s2 * iv.mpf(\'32.47\'))):\n print(f" {name} <= {P(v.b, 8)}")\nassert (s2 * iv.mpf(\'5.793\')).b < mpf(\'8.193\') and (s2 * iv.mpf(\'64.94\')).b < mpf(\'91.84\')\nassert (s2 * iv.mpf(\'2.543\')).b < mpf(\'3.597\') and (s2 * iv.mpf(\'32.47\')).b < mpf(\'45.92\')\nfor n in (24,):\n A = n * s2 * iv.mpf(\'5.793\'); Bc = n * s2 * iv.mpf(\'64.94\') + iv.mpf(\'1.1986\')\n assert A.b < 197 and Bc.b < 2206\n A = n * s2 * iv.mpf(\'2.543\'); Bc = n * s2 * iv.mpf(\'32.47\') + iv.mpf(\'0.5993\')\n assert A.b < 87 and Bc.b < 1103\nprint(" n = 24 reproduces 197 beta_W + 2206 and 87 beta_W + 1103 of thm:site")\n\n# ---------------------------------------------------------------- Part D\nprint("Part D: exact enumeration of the chains on a line of blocks")\n\n\ndef chains(bad, L, p):\n """Chains of a set of bad blocks on the line 0..L-1 (indices j), with p\n active inside links per block. Links: (\'P\', j, a) private links of the\n pair j (a = 0 the path link), (\'U\', j, a) inside links of block j."""\n js = sorted(bad)\n comps, cur = [], []\n for j in js:\n if cur and j - cur[-1] > 2:\n comps.append(cur); cur = []\n cur.append(j)\n if cur:\n comps.append(cur)\n out = []\n for c in comps:\n j0, j1 = c[0], c[-1]\n C = set()\n for j in c:\n C |= {(\'P\', j, a) for a in range(8)}\n for j in range(j0, j1 + 2):\n C |= {(\'U\', j, a) for a in range(1, p + 1)}\n for j in range(j0 - 1, j1 + 2):\n if j not in bad:\n C.add((\'P\', j, 0))\n out.append((j0, j1, len(c), C))\n return out\n\n\ndef constraint(j, p):\n return ({(\'P\', j, a) for a in range(8)} | {(\'U\', j, a) for a in range(1, p + 1)}\n | {(\'U\', j + 1, a) for a in range(1, p + 1)})\n\n\nL = 15\nchecked = 0\nviol_s1 = 0\nfor p in (7, 6, 4):\n for mask in range(1 << (L - 6)):\n bad = {j + 3 for j in range(L - 6) if mask >> j & 1} # bad blocks in 3..L-4\n if not bad:\n continue\n ch = chains(bad, L, p)\n allC = set()\n for (j0, j1, nb, C) in ch:\n # (i) disjointness\n assert not (allC & C)\n allC |= C\n # (iv) count\n assert len(C) == 8 * nb + p * (j1 - j0 + 2) + (j1 - j0 + 3 - nb)\n if p == 7:\n assert len(C) == 7 * nb + 8 * (j1 - j0) + 17\n # links of C are based within distance 1 of a bad block\n for (kind, j, a) in C:\n assert min(abs(j - b) for b in bad) <= 1\n # constraints: which pairs see C, and what else they see\n for j in range(L - 1):\n K = constraint(j, p)\n if not (K & C):\n continue\n assert j0 - 1 <= j <= j1 + 1\n ext = K - C\n for (kind, jj, a) in ext:\n if kind == \'P\': # non-path private link of a good pair\n assert a != 0 and jj not in bad and jj == j\n else: # inside link of block j0-1 or j1+2\n assert jj in (j0 - 1, j1 + 2)\n if j in bad:\n assert (\'P\', j, 0) in C and not ext & {(\'P\', j, a) for a in range(8)}\n for j in range(j0 - 1, j1 + 2):\n assert constraint(j, p) & C\n assert len(C) <= 23 * nb + 1\n # every bad pair\'s private links lie in exactly one chain\n for b in bad:\n assert all((\'P\', b, a) in allC for a in range(8))\n # windows: a block w with dist(w, bad) >= s+1; the window frees the\n # private and inside links of w and the path link of the pair w-1\n # entering it, and imposes the constraints of the pairs w and w-1\n for s in (1, 2, 3):\n for w in range(1, L - 1):\n if min(abs(w - b) for b in bad) < s + 1:\n continue\n free = ({(\'P\', w, a) for a in range(8)} | {(\'U\', w, a) for a in range(1, p + 1)}\n | {(\'P\', w - 1, 0)})\n cons = constraint(w, p) | constraint(w - 1, p)\n hit = (free | cons) & allC\n if s >= 2:\n assert not hit\n elif hit:\n viol_s1 += 1\n checked += 1\nprint(f" {checked} bad patterns (p = 7, 6, 4): chains disjoint, counts exact, "\n f"n <= 23 n_b + 1, exterior links of chain constraints as stated, "\n f"windows of collar s >= 2 "\n f"disjoint from chains")\nprint(f" collar s = 1: {viol_s1} (pattern, window) incidences, e.g. the end path link "\n f"of a chain entering a window block at distance 2")\nassert viol_s1 > 0\n\n# ---------------------------------------------------------------- Part E\nprint("Part E: the island threshold of thm:islandthreshold")\nM, H = mpf(11) ** 4, mpf(6) ** 4\nC0 = mpf(1) / 2 + mpf(2) / 3 * log(24 * pi ** 3)\nprint(" C0 =", P(C0, 12))\n\n\ndef logq(s):\n D = (4 * s + 3) ** 4 - 1\n return -H * (log(2) + 2 * log(D)) - log(e * M * H)\n\n\ndef logq_iv(s):\n D = iv.mpf((4 * s + 3) ** 4 - 1)\n Hi, Mi = iv.mpf(H), iv.mpf(M)\n return -Hi * (iv.log(2) + 2 * iv.log(D)) - iv.log(iv.e * Mi * Hi)\n\n\ndef f_iv(b, rho):\n C0i = iv.mpf(1) / 2 + iv.mpf(2) / 3 * iv.log(24 * iv.pi ** 3)\n return 6 * (iv.log(b) + C0i) - b * rho ** 2 / 16\n\n\nfor s in (1, 2, 5):\n print(f" s={s}: Delta={(4*s+3)**4-1}, log q* = {P(logq(s), 9)}")\nfor rho in (\'1e-8\', \'1e-9\'):\n for s in (1, 2, 5):\n r = mpf(rho)\n target = logq(s)\n f = lambda b: 6 * (log(b) + C0) - b * r ** 2 / 16 - target\n b = findroot(f, 16 * abs(target) / r ** 2 * mpf(\'1.01\'))\n lo, hi = b * (1 - mpf(\'1e-7\')), b * (1 + mpf(\'1e-7\'))\n ri, ti = iv.mpf(rho), logq_iv(s)\n assert (f_iv(iv.mpf(lo), ri) - ti).a > 0 and (f_iv(iv.mpf(hi), ri) - ti).b < 0\n assert b > 96 / r ** 2\n print(f" beta*({rho}, {s}) in [{P(lo, 9)}, {P(hi, 9)}]")\nprint("all checks passed")\n', 'd5/fold_certificate.py': '"""Rigorous (interval-arithmetic) verification for the fold obstruction,\nProposition fold. Everything printed as \'CHECK ... OK\' is a verified inequality.\nRun: python3 fold_certificate.py (about 1-3 minutes)\n"""\nimport time\nfrom fold_intervals import *\nt0 = time.time()\nSQ2 = iv.sqrt(iv.mpf(2))\nALPHA = 2 * (iv.pi / 2 - iatan(iv.sqrt(iv.mpf(7)))) # alpha = acos(3/4) = 2 asin(1/(2 sqrt2)); pi/2 - atan(sqrt 7) = asin(1/(2sqrt2))? no: use acos(3/4) = atan(sqrt7/3)\nALPHA = iatan(iv.sqrt(iv.mpf(7)) / 3) # acos(3/4) = atan(sqrt(7)/3)\nprint("alpha = acos(3/4) =", ALPHA)\nQ_LO = I(\'0.49\') - ALPHA; Q_HI = I(\'-0.5\') + ALPHA\nprint("q_lo = 0.49 - alpha =", Q_LO, " q_hi = -1/2 + alpha =", Q_HI)\nassert lo(Q_LO) > -0.233 and hi(Q_HI) < 0.223\nprint("CHECK [q_lo, q_hi] subset of [-0.233, 0.223]: OK")\n\n# ---------- T1: the torus function f_0 --------------------------------------\nSUM = I(\'2.44\') # sum of the seven angles: -1/2 + 6*0.49\ndef chiR(q): # maximiser theta_1 = -1/2 (q >= -0.005)\n return 2 - 4 * SQ2 * iv.sin((q + I(\'0.5\')) / 2)\ndef chiL(q): # maximiser the six links at 0.49 (q <= -0.005)\n return 2 - 4 * SQ2 * iv.sin((I(\'0.49\') - q) / 2)\ndef fR(q): return q + chiR(q) * (SUM - 7 * q) / 8\ndef fL(q): return q + chiL(q) * (SUM - 7 * q) / 8\ndef fRp(q): return 1 - 7 * chiR(q) / 8 - 2 * SQ2 * iv.cos((q + I(\'0.5\')) / 2) * (SUM - 7 * q) / 8\ndef fLp(q): return 1 - 7 * chiL(q) / 8 + 2 * SQ2 * iv.cos((I(\'0.49\') - q) / 2) * (SUM - 7 * q) / 8\ndef fRpp(q):\n chip = -2 * SQ2 * iv.cos((q + I(\'0.5\')) / 2); chipp = SQ2 * iv.sin((q + I(\'0.5\')) / 2)\n return chipp * (SUM - 7 * q) / 8 - 7 * chip / 4\n\n# consistency of the explicit formula with the quaternion code on the torus\nfor qq in [\'-0.2\', \'-0.05\', \'0.0\', \'0.1\', \'0.2\']:\n V, chi, m = V_of(I(qq), D(0))\n ang = iatan(V[1].v / V[0].v) # V in T, V_0 > 0 here\n f = fR(I(qq)) if mpf(qq) >= -0.005 else fL(I(qq))\n assert lo(ang) <= hi(f) and lo(f) <= hi(ang), (qq, ang, f)\nprint("CHECK explicit f_0 agrees with the quaternion V on the torus: OK")\n\n# (a) maximiser switch at q_s = -0.005: q+1/2 = 0.49-q\n# (b) convexity on [-0.005, q_hi]: by hand (signs); interval check of f\'\' > 0 anyway\nqs = [mpf(-0.005) + (hi(Q_HI) + mpf(0.005)) * k / 40 for k in range(41)]\nassert all(lo(fRpp(iv.mpf([qs[k], qs[k + 1]]))) > 0 for k in range(40))\nprint("CHECK f_0\'\' > 0 on [-0.005, q_hi]: OK")\n# (c) bracket of the minimiser q*\na, b = I(\'0.0741\'), I(\'0.0742\')\nassert hi(fRp(a)) < 0 and lo(fRp(b)) > 0\nprint("CHECK f_0\'(0.0741) < 0 < f_0\'(0.0742): OK, f_0\'(0.0741) in", fRp(a), " f_0\'(0.0742) in", fRp(b))\ngam_lo = lo(fR(a) + fRp(a) * (b - a)); gam_hi = min(hi(fR(a)), hi(fR(b)))\nGAM = iv.mpf([gam_lo, gam_hi])\nprint("gamma* = f_0(q*) in", GAM, " (by convexity: f_0(q) >= f_0(a) + f_0\'(a)(q-a))")\n# (d) f_0\'(-0.005+) < 0 and f_0\'(q_hi) > 0 (so q* is interior); f_0(-0.005) > gamma*\nassert hi(fRp(I(\'-0.005\'))) < 0 and lo(fRp(Q_HI)) > 0 and lo(fR(I(\'-0.005\'))) > gam_hi\nprint("CHECK f_0\'(-0.005) in", fRp(I(\'-0.005\')), "< 0; f_0\'(q_hi) in", fRp(Q_HI), "> 0; f_0(-0.005) in", fR(I(\'-0.005\')), "> gamma*: OK")\n# (e) f_0 increasing on [q_lo, -0.005]: f\' >= 1 - 7 chi/8 with chi <= chi(-0.005)\nchimax = chiL(I(\'-0.005\'))\nassert hi(chimax) < 0.6146 and lo(1 - 7 * chimax / 8) > 0.46\nprint("CHECK chi(-0.005) in", chimax, "<= 0.6146, so f_0\' > 0.46 on [q_lo,-0.005]: OK")\n# (f) q_L(lambda) for lambda in Lambda = [gamma* - 1e-3, gamma* + 1e-3]\nETA = mpf(\'0.001\')\nqL1, qL2 = I(\'-0.0172\'), I(\'-0.0156\')\nassert hi(fL(qL1)) < gam_lo - ETA and lo(fL(qL2)) > gam_hi + ETA\nprint("CHECK f_0(-0.0172) in", fL(qL1), "< gamma*-1e-3 and f_0(-0.0156) in", fL(qL2), "> gamma*+1e-3: OK")\nprint(" so q_L(lambda) in [-0.0172, -0.0156] for every lambda in Lambda, and q* - q_L >= 0.0741+0.0156 = 0.0897")\nGAP = 2 * SQ2 * iv.sin(I(\'0.0897\') / 2)\nprint(" chordal distance delta(g*, g_L(lambda)) >= 2 sqrt2 sin(0.0897/2) >=", lo(GAP))\nassert lo(GAP) > 0.1268\n# (g) f_0\'(q_L) >= 1.3 (actual) -- use the explicit derivative on the bracket\nfpL = fLp(iv.mpf([lo(qL1), hi(qL2)]))\nprint(" f_0\'(q) on [-0.0172,-0.0156] in", fpL)\nassert lo(fpL) > 1.3\n# (h) the near-side roots q_+- lie in [q*-0.021, q*+0.021] subset (-0.005, q_hi): f\'\' >= 4.6\nassert lo(fRpp(iv.mpf([mpf(\'0.05\'), mpf(\'0.1\')]))) > 4.6\nprint("CHECK f_0\'\' > 4.6 on [0.05, 0.1]: OK (so |q_+- - q*| <= sqrt(2e-3/4.6) < 0.021 for lambda in Lambda)")\n\n# ---------- T2: the strip s in [0, s1]: dV_k/ds > 0 -----------------------------\nS1 = mpf(\'0.02\')\ndef strip(q0, q1, depth=0):\n V, chi, m = V_of(iv.mpf([q0, q1]), D(iv.mpf([0, S1]), 1))\n dk = V[3].d; dj = V[2].d\n if lo(dk) > 0:\n return [(lo(dk), hi(dk), hi(abs(dj)))], 1\n if depth > 30: raise RuntimeError("strip: no positive enclosure at %s" % ((q0, q1),))\n mid = (q0 + q1) / 2\n r1, n1 = strip(q0, mid, depth + 1); r2, n2 = strip(mid, q1, depth + 1)\n return r1 + r2, n1 + n2\nres, nbox = strip(mpf(\'-0.233\'), mpf(\'0.223\'))\nprint("CHECK strip q in [-0.233,0.223], s in [0,%s]: dV_k/ds > 0 on every box (%d boxes): OK" % (S1, nbox))\n# finer enclosures on the two q-ranges that enter the constants\ndef fine(q0, q1, n):\n out = []\n for k in range(n):\n a = q0 + (q1 - q0) * k / n; b = q0 + (q1 - q0) * (k + 1) / n\n V, chi, m = V_of(iv.mpf([a, b]), D(iv.mpf([0, S1]), 1))\n out.append((lo(V[3].d), hi(V[3].d), hi(abs(V[2].d))))\n return min(r[0] for r in out), max(r[1] for r in out), max(r[2] for r in out)\nKAPPA, _, _ = fine(mpf(\'-0.0172\'), mpf(\'-0.0156\'), 16)\n_, LMAX, DJMAX = fine(mpf(\'0.05\'), mpf(\'0.1\'), 50)\nprint(" on q in [-0.0172,-0.0156] (the atom g_L): dV_k/ds >= kappa =", KAPPA)\nprint(" on q in [0.05,0.1] (the atoms g_+-): dV_k/ds <=", LMAX, ", |dV_j/ds| <=", DJMAX)\nassert KAPPA > 0.49\n\n# ---------- T3: the region s in [s1, alpha]: V_k > 0 ----------------------------\ncount = [0]\ndef region(q0, q1, s0, s1, depth=0):\n count[0] += 1\n V, chi, m = V_of(iv.mpf([q0, q1]), D(iv.mpf([s0, s1])))\n if lo(V[3].v) > 0: return\n if depth > 40: raise RuntimeError("region: cannot exclude box %s" % ((q0, q1, s0, s1),))\n if (q1 - q0) > (s1 - s0):\n mid = (q0 + q1) / 2; region(q0, mid, s0, s1, depth + 1); region(mid, q1, s0, s1, depth + 1)\n else:\n mid = (s0 + s1) / 2; region(q0, q1, s0, mid, depth + 1); region(q0, q1, mid, s1, depth + 1)\nregion(mpf(\'-0.233\'), mpf(\'0.223\'), S1, hi(ALPHA))\nprint("CHECK region q in [-0.233,0.223], s in [%s, alpha]: V_k > 0 on every box (%d boxes examined): OK" % (S1, count[0]))\nprint("Hence V^{-1}(T) = T: every path link g with V(g) in the torus lies in the torus.")\n\n# ---------- constants for the W_1 jump ----------------------------------------\nwL_max = 1 / (lo(fpL) * KAPPA ** 2)\nprint("weight of the atom g_L: w_L <= 1/(f_0\'(q_L) kappa^2) <=", wL_max, "(times e^{-beta S} <= 1)")\nprint("transverse factor at any torus point of the strip: |lambda_perp| = |dV/ds(q,0)| <= sqrt(LMAX^2+DJMAX^2) <=", mp.sqrt(LMAX**2 + DJMAX**2))\nprint("done in %.1f s" % (time.time() - t0))\n', 'd5/fold_intervals.py': '"""Rigorous interval arithmetic (mpmath.iv) with forward-mode derivatives\n("Dual" = interval value + interval enclosure of an a.e. derivative), and the\ncut-off average V of one pair with its seven non-path links on the diagonal\ntorus and every other link equal to I.\n\nQuaternion conventions: (a,b,c,d) = a + b i + c j + d k, |.| = 1;\ntorus T = {cos q + i sin q} = diag(e^{iq}, e^{-iq}); chordal HS distance\ndelta(v,I) = 2 sqrt(1 - v_0) = 2 sqrt2 |sin(psi/2)|; rho_G = 1.\nV(g) = g Exp( chi(m) (1/8) sum_a Log(g^{-1} l_a) ), m = max_a delta(g^{-1} l_a, I),\nchi = min(1, max(0, 2 - 2m)), the two offset-zero paths contributing log I = 0\nand every other private link occurring in two paths.\n\natan is not provided by mpmath.iv; it is enclosed by endpoint evaluation at\n90 bits widened by 2^-80 (see iatan), which relies on mpmath\'s atan being\naccurate to far better than 2^-80 at that precision.\n"""\nfrom mpmath import iv, mp, mpf\niv.prec = 60\nmp.prec = 90\nWID = mpf(2) ** -80\n\ndef lo(x):\n a = mp.mpf(); a._mpf_ = x._mpi_[0]; return a\ndef hi(x):\n a = mp.mpf(); a._mpf_ = x._mpi_[1]; return a\ndef I(a, b=None):\n return iv.mpf([a, b]) if b is not None else iv.mpf(a)\ndef hull(x, y):\n return iv.mpf([min(lo(x), lo(y)), max(hi(x), hi(y))])\ndef imax(x, y):\n return iv.mpf([max(lo(x), lo(y)), max(hi(x), hi(y))])\ndef imin(x, y):\n return iv.mpf([min(lo(x), lo(y)), min(hi(x), hi(y))])\ndef iatan(x):\n a = mp.atan(lo(x)) - WID; b = mp.atan(hi(x)) + WID\n return iv.mpf([a, b])\n\nclass D:\n """interval value v, interval enclosure d of its s-derivative."""\n __slots__ = ("v", "d")\n def __init__(s, v, d=None):\n s.v = v if isinstance(v, type(iv.mpf(0))) else iv.mpf(v)\n s.d = iv.mpf(0) if d is None else (d if isinstance(d, type(iv.mpf(0))) else iv.mpf(d))\n def __add__(s, o):\n o = o if isinstance(o, D) else D(o); return D(s.v + o.v, s.d + o.d)\n __radd__ = __add__\n def __neg__(s): return D(-s.v, -s.d)\n def __sub__(s, o):\n o = o if isinstance(o, D) else D(o); return D(s.v - o.v, s.d - o.d)\n def __rsub__(s, o): return D(o) - s\n def __mul__(s, o):\n o = o if isinstance(o, D) else D(o); return D(s.v * o.v, s.d * o.v + s.v * o.d)\n __rmul__ = __mul__\n def __truediv__(s, o):\n o = o if isinstance(o, D) else D(o)\n return D(s.v / o.v, (s.d * o.v - s.v * o.d) / (o.v * o.v))\n\ndef dsin(x): return D(iv.sin(x.v), iv.cos(x.v) * x.d)\ndef dcos(x): return D(iv.cos(x.v), -iv.sin(x.v) * x.d)\ndef dsqrt(x):\n r = iv.sqrt(x.v); return D(r, x.d / (2 * r))\ndef datan(x): return D(iatan(x.v), x.d / (1 + x.v * x.v))\ndef dmax(x, y):\n v = imax(x.v, y.v)\n if lo(x.v) > hi(y.v): d = x.d\n elif lo(y.v) > hi(x.v): d = y.d\n else: d = hull(x.d, y.d)\n return D(v, d)\ndef dphi(m):\n """chi = min(1, max(0, 2 - 2m)), decreasing in m; derivative -2 on (1/2,1), 0 outside."""\n def phi(t): return min(mpf(1), max(mpf(0), 2 - 2 * t))\n v = iv.mpf([phi(hi(m.v)), phi(lo(m.v))])\n a, b = lo(m.v), hi(m.v)\n if b < mpf(1) / 2 or a > 1: d = iv.mpf(0)\n elif a > mpf(1) / 2 and b < 1: d = -2 * m.d\n else: d = hull(iv.mpf(0), -2 * m.d)\n return D(v, d)\n\ndef alt_series(u, coeffs):\n """sum_k coeffs[k] u^k, alternating signs with decreasing terms assumed\n verified by caller (|coeffs[k+1]| u <= |coeffs[k]|); enclosure is the hull\n of the last two partial sums (interval arithmetic throughout)."""\n S = iv.mpf(0); P = iv.mpf(1); parts = []\n for c in coeffs:\n S = S + c * P; parts.append(S); P = P * u\n return hull(parts[-1], parts[-2])\n\nfrom math import factorial\nK = 8\nC_COS = [iv.mpf((-1) ** k) / factorial(2 * k) for k in range(K)] # cos sqrt(u)\nC_SINC = [iv.mpf((-1) ** k) / factorial(2 * k + 1) for k in range(K)] # sin sqrt(u)/sqrt(u)\nC_DSINC = [iv.mpf((-1) ** k) * k / factorial(2 * k + 1) for k in range(1, K)] # d/du sinc sqrt(u)\n\nWIDE = D(iv.mpf([-1, 1]), iv.mpf([-10, 10]))\ndef dcosroot(u): # cos sqrt(u) as a function of u >= 0; series valid for hi(u) <= 2\n if hi(u.v) > 2: return WIDE # harmless: the box then fails every test and is split\n return D(alt_series(u.v, C_COS), -alt_series(u.v, C_SINC) / 2 * u.d)\ndef dsincroot(u): # sin sqrt(u)/sqrt(u)\n if hi(u.v) > 2: return WIDE\n return D(alt_series(u.v, C_SINC), alt_series(u.v, C_DSINC) * u.d)\n\ndef qmul(p, q):\n a1, b1, c1, d1 = p; a2, b2, c2, d2 = q\n return (a1*a2 - b1*b2 - c1*c2 - d1*d2,\n a1*b2 + b1*a2 + c1*d2 - d1*c2,\n a1*c2 - b1*d2 + c1*a2 + d1*b2,\n a1*d2 + b1*c2 - c1*b2 + d1*a2)\ndef qinv(p): return (p[0], -p[1], -p[2], -p[3])\n\nTHETA = [I(\'-0.5\')] + [I(\'0.49\')] * 6\n\ndef V_of(q, s, theta=THETA):\n """q: interval (no s-dependence); s: D. Returns (V as 4 Duals, chi, m)."""\n cq, sq = iv.cos(q), iv.sin(q)\n cs, ss = dcos(s), dsin(s)\n g = (cs * cq, cs * sq, D(0), ss)\n gi = qinv(g)\n logs = []; m = D(0)\n for th in theta:\n l = (D(iv.cos(th)), D(iv.sin(th)), D(0), D(0))\n v = qmul(gi, l)\n delta = 2 * dsqrt(1 - v[0])\n m = dmax(m, delta)\n n2 = v[1] * v[1] + v[2] * v[2] + v[3] * v[3]\n n = dsqrt(n2)\n t = n / (1 + v[0])\n lam = 2 * datan(t) / n\n logs.append((lam * v[1], lam * v[2], lam * v[3]))\n chi = dphi(m)\n N = [sum((L[i] for L in logs), D(0)) / 8 for i in range(3)]\n w = [chi * N[i] for i in range(3)]\n u = w[0] * w[0] + w[1] * w[1] + w[2] * w[2]\n C = dcosroot(u); Sc = dsincroot(u)\n E = (C, Sc * w[0], Sc * w[1], Sc * w[2])\n V = qmul(g, E)\n return V, chi, m\n\ndef f0_torus(q):\n """angle of V on the torus (interval q), via atan2 of components, and the\n explicit formula on [-0.005, 0.2227] (maximiser theta_1 = -1/2)."""\n V, chi, m = V_of(q, D(0))\n return V, chi, m\n', 'd5/fold_selftest.py': 'from fold_intervals import *\nimport numpy as np\n# floating-point reference evaluation (from the exploration script)\n# Floating-point exploration of the branch structure of the cut-off average\n# of one pair with its seven non-path links frozen (Prop. prop:branches data),\n# all other links at I. Quaternion conventions: (a,b,c,d) = a+bi+cj+dk,\n# torus = {cos q + i sin q} <-> diag(e^{iq}, e^{-iq}); chordal HS distance\n# delta(v,I) = 2 sqrt2 |sin(psi/2)|, psi = eigenangle; rho_G = 1.\nimport numpy as np\nfrom numpy import cos, sin, sqrt, pi\n\ndef qmul(p, q):\n a1,b1,c1,d1 = p; a2,b2,c2,d2 = q\n return np.array([a1*a2-b1*b2-c1*c2-d1*d2,\n a1*b2+b1*a2+c1*d2-d1*c2,\n a1*c2-b1*d2+c1*a2+d1*b2,\n a1*d2+b1*c2-c1*b2+d1*a2])\ndef qinv(p): return np.array([p[0],-p[1],-p[2],-p[3]])\ndef qlog(v): # principal log, pure imaginary part, |.|=psi in [0,pi]\n n = np.linalg.norm(v[1:]); psi = np.arctan2(n, v[0])\n return (psi/n)*v[1:] if n>1e-300 else np.zeros(3)\ndef qexp(w):\n n = np.linalg.norm(w)\n return np.array([cos(n), *((sin(n)/n)*w)]) if n>1e-300 else np.array([1.,0,0,0])\ndef chordal(v): return 2*sqrt(2)*sqrt(max(0.,1-v[0]**2)) if False else sqrt(2)*np.linalg.norm(v-np.array([1,0,0,0]))\ndef phi(m): return min(1., max(0., 2-2*m))\ndef torus(q): return np.array([cos(q), sin(q), 0, 0])\n\ntheta = np.array([-0.5] + [0.49]*6) # seven non-path links\nL = [torus(t) for t in theta]\n\ndef Vsharp(g, L=L):\n vs = [qmul(qinv(g), l) for l in L]\n m = max(chordal(v) for v in vs)\n chi = phi(m)\n N = sum(qlog(v) for v in vs)/8.0\n return qmul(g, qexp(chi*N)), chi, m\n\ndef f0(q): # scalar angle of V on the torus\n V, chi, m = Vsharp(torus(q)); return np.arctan2(V[1], V[0])\n\n\ndef gS(q, s): return np.array([cos(s)*cos(q), cos(s)*sin(q), 0., sin(s)])\n# compare interval V with floating V at a few points, and derivative with finite differences\nfor (q, s) in [(0.0, 0.0), (0.05, 0.3), (-0.1, 0.1), (0.2, 0.6), (-0.2, 0.02)]:\n V, chi, m = V_of(I(q), D(s, 1))\n Vf, chif, mf = Vsharp(gS(q, s)); Vf2, _, _ = Vsharp(gS(q, s + 1e-7))\n for i in range(4):\n assert lo(V[i].v) - 1e-12 <= Vf[i] <= hi(V[i].v) + 1e-12, (q, s, i, V[i].v, Vf[i])\n fd = (Vf2[i] - Vf[i]) / 1e-7\n assert lo(V[i].d) - 1e-5 <= fd <= hi(V[i].d) + 1e-5, (q, s, i, V[i].d, fd)\n assert lo(chi.v) - 1e-12 <= chif <= hi(chi.v) + 1e-12 and lo(m.v) - 1e-12 <= mf <= hi(m.v) + 1e-12, (chi.v, chif, m.v, mf)\n print("ok", q, s, [float(hi(V[i].v) - lo(V[i].v)) for i in range(4)], float(hi(V[3].d) - lo(V[3].d)))\n# box containment test: random points in a box\nimport random\nq0, q1, s0, s1 = -0.01, 0.0, 0.0, 0.02\nV, chi, m = V_of(I(q0, q1), D(I(s0, s1), 1))\nfor _ in range(200):\n q = random.uniform(q0, q1); s = random.uniform(s0, s1)\n Vf, _, _ = Vsharp(gS(q, s))\n for i in range(4): assert lo(V[i].v) - 1e-12 <= Vf[i] <= hi(V[i].v) + 1e-12\nprint("box ok; V_k box:", V[3].v, " dV_k/ds box:", V[3].d)\n', 'd5/frontier_calibration.py': '"""Small exact calibrations for A/B/C and finite-dimensional D8/E examples.\n\nAnalytic statements and their hypotheses are in FRONTIER_LEMMAS.md.\nNo numerical output is a Yang--Mills continuum theorem.\n"""\nfrom fractions import Fraction as F\nfrom math import factorial, exp\nimport json\nfrom pathlib import Path\n\n\ndef bessel_interval(order, kappa, terms=18):\n z=kappa/2\n total=sum((z**(2*k+order)/F(factorial(k)*factorial(k+order)) for k in range(terms)),F(0))\n nxt=z**(2*terms+order)/F(factorial(terms)*factorial(terms+order))\n ratio=z*z/F((terms+1)*(terms+order+1))\n return total,total+nxt/(1-ratio)\n\n\ndef oscillator_diag(n, power):\n states={n:F(1)}\n # Unnormalised number basis: creation coefficient 1, annihilation coefficient n.\n for _ in range(power):\n out={}\n for j,c in states.items():\n out[j+1]=out.get(j+1,F(0))+c\n if j:out[j-1]=out.get(j-1,F(0))+j*c\n states=out\n assert power%2==0\n return states.get(n,F(0))/2**(power//2)\n\nresult={\'classification\':\'exact finite checks and numerical toy examples; no continuum or full block bound\'}\nresponses=[]\nfor beta in [F(351,1000),F(355,1000)]:\n l1,u1=bessel_interval(1,beta);l2,u2=bessel_interval(2,beta)\n lo,hi=(1+l2/u1)/4,(1+u2/l1)/4\n assert hi-lop**H\nresult[\'C_witness_limit\']={\'labels\':H,\'probability_all\':str(p),\'invalid_independent_bound\':str(p**H)}\n# Dense rank-one perturbation of identity: form control, but no uniform exponential locality.\nepsilon=F(1,2)\nresult[\'D8_dense_inverse\']=[{\'n\':n,\'endpoint_inverse\':str(-epsilon/((1+epsilon)*n))} for n in [16,64,256]]\n# Vanishing observable normalisation with a fixed positive physical gap.\nresult[\'E_trivial_normalization\']=[{\'a\':a,\'mass\':1,\'correlation_at_t1\':a*a*exp(-1)} for a in [1,.1,.01,.001]]\n# Jensen spectral bound on a finite positive measure, illustrating the proof.\nweights=[F(1,4),F(3,4)];energies=[F(1),F(5)];v=sum(weights);M=sum(w*e for w,e in zip(weights,energies))\nfor t in [.1,1,3]:\n actual=sum(float(w)*exp(-t*float(e)) for w,e in zip(weights,energies))\n lower=float(v)*exp(-t*float(M/v))\n assert actual>=lower-1e-15\nresult[\'E_spectral_budget\']={\'variance\':str(v),\'first_moment\':str(M),\'jensen_checks\':\'passed\'}\nPath(\'result.json\').write_text(json.dumps(result,indent=2,sort_keys=True)+\'\\n\')\nprint(json.dumps(result,indent=2,sort_keys=True))\n', 'd5/frontier_diagnostics.py': '"""Finite diagnostics only: a scalar fold and a convex scalar collar, not SU(2) transport."""\nimport json\nimport math\nfrom pathlib import Path\nimport time\nimport numpy as np\nfrom numpy.polynomial.legendre import leggauss\nfrom scipy.optimize import brentq\n\nstarted = time.monotonic()\ndef grid(n, lo, hi):\n x, w = leggauss(n)\n return lo+(x+1)*(hi-lo)/2, w*(hi-lo)/2\n\ndef f(q, t):\n chi = 2-4*np.sqrt(2)*np.sin((q-t)/2)\n return q+chi*(t+2.94-7*q)/8\n\ndef ft(q, t):\n chi = 2-4*np.sqrt(2)*np.sin((q-t)/2)\n return (chi+2*np.sqrt(2)*np.cos((q-t)/2)*(t+2.94-7*q))/8\n\ndef fq(q, t):\n chi = 2-4*np.sqrt(2)*np.sin((q-t)/2)\n return 1-7*chi/8-2*np.sqrt(2)*np.cos((q-t)/2)*(t+2.94-7*q)/8\n\ndef bump(x):\n x=np.asarray(x); a=1-x*x\n return np.exp(-1/np.maximum(a,1e-300))*(a>0)\n\nqstar=brentq(lambda q: fq(q,-.5), .04,.18)\ncritical=float(f(qstar,-.5))\ndef density(n, gamma):\n q,w=grid(n,.04,.18)\n lo=np.full(n,-.54);hi=np.full(n,-.46)\n valid=(f(q,lo).1)*np.exp(-10*(x-.7)**2)\n b0=w*(x<-.1)*np.exp(-12*(x+.6)**2)\n b1=w*(x>0)*(np.exp(-20*(x-.8)**2)+.4*np.exp(-30*(x-.3)**2))\n out=[]\n for length in range(1,10):\n K=E@P@E.T\n lk=np.log(K)\n delta=max(float(np.max(np.ptp(lk[i][None,:]-lk,axis=1))) for i in range(nq))\n Z=np.array([[a@K@b for b in [b0,b1]] for a in [a0,a1]])\n logR=float(np.log(Z[1,1])+np.log(Z[0,0])-np.log(Z[1,0])-np.log(Z[0,1]))\n assert abs(logR)<=delta+1e-12\n # Exact unbounded Gaussian collar control, separately from the bounded quartic model.\n A=2*np.eye(length)-J*(np.eye(length,k=1)+np.eye(length,k=-1))\n inv=np.linalg.inv(A);gaussian_delta=4*J*J*inv[0,-1]\n out.append({\'length\':length,\'kernel_log_cross_ratio_bound\':delta,\'island_log_odds\':logR,\'gaussian_control_delta\':float(gaussian_delta)})\n P=(P@T)*d[None,:]\n return out\n\ncollars=[{\'nodes\':n,\'rows\':collar(n)} for n in [48,96]]\n# Hard label jumps limit ordinary Gauss quadrature accuracy; compare kernel separately.\nassert max(abs(a[\'kernel_log_cross_ratio_bound\']-b[\'kernel_log_cross_ratio_bound\']) for a,b in zip(collars[0][\'rows\'],collars[1][\'rows\']))<.002\n\n# Positive-time spectral criterion: independent finite positive measures.\nspectral=[]\ns=.4\nfor a in [.1,.05,.025]:\n energies=np.array([1.,3.,1/a]); masses=np.array([.4,.3,.3])\n C=lambda t:float(np.dot(masses,np.exp(-t*energies)))\n ratio=C(s)/C(s/2)\n moment=float(np.dot(masses,energies*np.exp(-s*energies))/C(s))\n bound=2/(math.e*s*ratio)\n assert moment<=bound\n assert C(s+.7)/C(s)>=math.exp(-bound*.7)\n spectral.append({\'a\':a,\'physical_time_ratio\':ratio,\'normalised_energy\':moment,\'moment_bound\':bound,\'escaping_only_ratio\':math.exp(-s/(2*a))})\n\nreport={\'classification\':\'deterministic floating diagnostics; scalar examples only, no gauge-theory bound\',\n \'fold\':fold,\'mollified_delta\':mollified,\'collars\':collars,\'spectral\':spectral,\'seconds\':time.monotonic()-started}\nPath(\'result.json\').write_text(json.dumps(report,indent=2)+\'\\n\')\nprint(json.dumps(report,sort_keys=True),flush=True)\n', 'd5/goodside_constants.py': '"""Constants of Proposition goodside (the good side to r <= 1/32)."""\nfrom mpmath import mp, mpf, sin, pi, sqrt\nmp.dps = 30\nr = mpf(1)/32\nprint("16 r =", 16*r, " (<= 1/2: cut-off equals one at every branch)")\ntheta = 16*r/sqrt(2) # largest eigenangle of Y = log(e^{-X}A_x), ||Y|| <= 16 r\nL = theta/sin(theta)\nprint("theta = 16r/sqrt2 =", theta, " theta/sin theta =", L)\nk = mpf(7)/8*L\nprint("contraction constant (7/8) theta/sin theta =", k, " < 0.8936:", k < mpf(\'0.8936\'))\nprint("singular values of the path-link derivative in [1-k, 1+k] = [", 1-k, ",", 1+k, "]")\nprint("|det| in [", (1-k)**3, ",", (1+k)**3, "]")\nprint("response to one non-path private link: (2/16) L /(1-k) =", (2*L/16)/(1-k))\nprint("response to one inside link u_a or w_a: (1/16) L /(1-k) =", (L/16)/(1-k))\nprint("pi/3 =", pi/3, " (conversion d <= (pi/3) delta for delta <= 1)")\n', 'd5/grid_check.py': '"""k_*(beta) - j_max(beta) on a fine logarithmic grid of couplings (s=5, rho=1e-8)."""\nfrom composed_threshold import composed, kstar\nfrom mpmath import mpf, log\nthr = [composed(j, 5)[4] for j in range(0, 20)] # beta*_j, increasing in j\nworst = 0; best = 99\nimport math\nfor t in range(0, 2001):\n beta = mpf(10)**(mpf(22) + mpf(20)*t/2000)\n jm = max(j for j in range(20) if thr[j] <= beta)\n k, _ = kstar(beta)\n worst = max(worst, k - jm); best = min(best, k - jm)\nprint("beta in [1e22,1e42], 2001 log-spaced points: k_* - j_max ranges over", best, "..", worst)\nprint("16^-j beta*_j max over j<=12:", float(max(thr[j]/16**j for j in range(1,13))))\n', 'd5/groups_threshold.py': '"""Certified constants for the island machinery of Section 13 on a compact\nsimple group G in a faithful unitary representation of dimension N.\n\nInterval arithmetic (mpmath.iv, 60 digits). Every printed number is the\nmidpoint of a certified interval together with the interval\'s endpoints;\ninequalities are checked on the interval endpoints.\n\nQuantities (notation of groups.tex):\n d = dim G, kappa = kappa_G, K = kappa/(d-1), I_d(pi) = int_0^pi sin^{d-1},\n C0(G) = 1/2 + (2/3)[log(d I_d(pi)) + (d/2) log(16/(K N)) - (d-1) log(95/96)],\n f_G(b) = 2 d log b + 6 C0(G) - b rho^2/(8N),\n log q* = -H (log 2 + 2 log D) - log(e M H), M = 11^4, H = 6^4,\n D = (4s+3)^4 - 1 (islands) or (4s+17)^4 - 1 (joining distance 2s+8),\n beta* = largest root of f_G = log q* (- H log Gamma).\n"""\nfrom fractions import Fraction as Fr\nfrom mpmath import iv, mp, mpf, log as mlog, findroot\nimport math\n\niv.dps = 60\nmp.dps = 60\n\ndef I_dpi(d):\n """I_d(pi) = int_0^pi sin^{d-1}u du, exactly: pi * rational or rational."""\n if d % 2 == 1: # d-1 even\n val = Fr(1) # I_1 = pi\n k = 1\n while k < d:\n k += 2\n val *= Fr(k - 2, k - 1)\n return (\'pi\', val)\n val = Fr(2) # I_2 = 2\n k = 2\n while k < d:\n k += 2\n val *= Fr(k - 2, k - 1)\n return (\'1\', val)\n\ndef ivq(q):\n return iv.mpf(q.numerator) / q.denominator\n\ndef I_iv(d):\n kind, val = I_dpi(d)\n return ivq(val) * (iv.pi if kind == \'pi\' else 1)\n\ndef C0(d, kappa, N):\n K = ivq(Fr(kappa)) / (d - 1)\n return (iv.mpf(1) / 2 + iv.mpf(2) / 3 * (iv.log(d * I_iv(d))\n + iv.mpf(d) / 2 * iv.log(16 / (K * N))\n - (d - 1) * iv.log(iv.mpf(95) / 96)))\n\ndef C0_paper_su2():\n return iv.mpf(1) / 2 + iv.mpf(2) / 3 * iv.log(24 * iv.pi ** 3)\n\nM, H = 11 ** 4, 6 ** 4\n\ndef logqstar(D, Mv=M, Hv=H):\n return -Hv * (iv.log(2) + 2 * iv.log(D)) - iv.log(iv.e * Mv * Hv)\n\ndef f(b, d, N, rho, c0):\n return 2 * d * iv.log(b) + 6 * c0 - b * rho ** 2 / (8 * N)\n\ndef lo_(x):\n return mpf(x.a)\n\ndef hi_(x):\n return mpf(x.b)\n\ndef mid(x):\n if not isinstance(x, iv.mpf):\n return mpf(x)\n return (mpf(x.a) + mpf(x.b)) / 2\n\ndef betastar(d, N, rho, c0, lq):\n """Certified bracket [lo, hi] of the largest root of f = lq."""\n rho_m, c0_m, lq_m = mid(iv.mpf(rho)), mid(c0), mid(lq)\n fm = lambda b: 2 * d * mlog(b) + 6 * c0_m - b * rho_m ** 2 / (8 * N) - lq_m\n b0 = 8 * N * (-lq_m) / rho_m ** 2\n b = findroot(fm, b0)\n peak = mpf(16) * d * N / rho_m ** 2\n assert b > peak\n lo, hi = b * (1 - mpf(10) ** -25), b * (1 + mpf(10) ** -25)\n flo = f(iv.mpf(lo), d, N, iv.mpf(rho), c0) - lq\n fhi = f(iv.mpf(hi), d, N, iv.mpf(rho), c0) - lq\n assert mpf(flo.a) > 0 and mpf(fhi.b) < 0, "bracket not certified"\n # f is concave with its maximum at 16 d N / rho^2 < lo, so the root in\n # [lo,hi] is the largest root; check the maximum lies above log q*.\n fpk = f(iv.mpf(peak), d, N, iv.mpf(rho), c0) - lq\n assert mpf(fpk.a) > 0\n assert peak < lo\n return lo, hi\n\ndef eps_of(lo, hi, N, rho, lq):\n # beta* = 8 N |log q*| rho^-2 (1+eps)\n base = 8 * N * (-lq) / iv.mpf(rho) ** 2\n return iv.mpf([lo, hi]) / base - 1\n\ndef show(x, digits=6):\n return mp.nstr(mid(x), digits)\n\ndef rng(x, digits=8):\n return f"[{mp.nstr(mpf(x.a), digits)}, {mp.nstr(mpf(x.b), digits)}]"\n\ndef sci(lo, hi, digits=5):\n return f"{mp.nstr(mpf(lo), digits)} .. {mp.nstr(mpf(hi), digits)}"\n\n# ---------------------------------------------------------------------------\ngroups = [\n # name, d, N, kappa, rho_G\n ("SU(2)", 3, 2, Fr(1), "1"),\n ("SU(3)", 8, 3, Fr(3, 2), "1"),\n ("SU(4)", 15, 4, Fr(2), "1"),\n ("SU(5)", 24, 5, Fr(5, 2), "1"),\n ("SU(10)", 99, 10, Fr(5), "1"),\n ("SO(3)", 3, 3, Fr(1, 4), "1"),\n ("SO(5)", 10, 5, Fr(3, 4), "1"),\n ("SO(10)", 45, 10, Fr(2), "1"),\n ("Sp(2)", 10, 4, Fr(3, 2), "1"),\n ("Sp(3)", 21, 6, Fr(2), "1"),\n ("G2", 14, 7, Fr(1), "0.99"),\n ("F4", 52, 26, Fr(3, 4), "0.99"),\n ("E6", 78, 27, Fr(1), "0.99"),\n ("E7", 133, 56, Fr(3, 4), "0.76"),\n ("E8", 248, 248, Fr(1, 4), "0.99"),\n]\n\nprint("== (A) Haar small-ball constant C0(G) and the hypothesis beta_W >= K N ==")\nprint("group d N kappa K N I_d(pi) C0(G)")\nc0s = {}\nfor name, d, N, kap, rG in groups:\n c0 = C0(d, kap, N)\n c0s[name] = c0\n KN = Fr(kap) * N / (d - 1)\n assert KN <= 1\n kind, val = I_dpi(d)\n Is = f"{val}*pi" if kind == \'pi\' else f"{val}"\n print(f"{name:7s} {d:3d} {N:4d} {str(kap):5s} {str(KN):9s} {Is:20s} "\n f"{rng(c0)}")\n assert mpf(c0.a) > 0\nprint("every K N <= 1, so Lemma (Wilson Z) applies at every beta_W >= 1;"\n " every C0(G) > 0")\nc0p = C0_paper_su2()\nprint(f"paper\'s SU(2) constant 1/2+(2/3)log(24 pi^3) = {rng(c0p)};"\n f" C0(SU(2)) of the general lemma = {rng(c0s[\'SU(2)\'])}")\nassert mpf(c0s[\'SU(2)\'].b) < mpf(c0p.a)\n\nprint()\nprint("== (B) log q* (group-free) ==")\nlqs = {}\nfor s in (1, 5):\n D = (4 * s + 3) ** 4 - 1\n Ds = (4 * s + 17) ** 4 - 1\n lqs[(s, \'isl\')] = logqstar(D)\n lqs[(s, \'join\')] = logqstar(Ds)\n print(f"s={s}: Delta={D}, |log q*|={rng(-lqs[(s,\'isl\')], 9)};"\n f" N_s={Ds}, |log q*|={rng(-lqs[(s,\'join\')], 9)}")\n\nprint()\nprint("== (C) consistency: SU(2) with the paper\'s C0 reproduces"\n " Theorem (island threshold) ==")\nfor rho, s in ((mpf(\'1e-8\'), 1), (mpf(\'1e-8\'), 5), (mpf(\'1e-9\'), 1),\n (mpf(\'1e-9\'), 5)):\n lo, hi = betastar(3, 2, rho, c0p, lqs[(s, \'isl\')])\n print(f"rho={mp.nstr(rho,2)}, s={s}: beta* in {sci(lo, hi, 7)}")\nlo, hi = betastar(3, 2, mpf(\'1e-8\'), c0p, lqs[(5, \'isl\')] - H * iv.log(iv.mpf(10) ** 30))\nprint(f"rho=1e-8, s=5, Gamma=1e30: beta* in {sci(lo, hi, 7)}")\n\nprint()\nprint("== (D) SU(3): f(b) = 16 log b + 6 C0 - b rho^2/24 ==")\nd, N = 8, 3\nc0 = c0s["SU(3)"]\nfor rho, s in ((mpf(\'1e-8\'), 1), (mpf(\'1e-8\'), 5), (mpf(\'1e-9\'), 1),\n (mpf(\'1e-9\'), 5)):\n lq = lqs[(s, \'isl\')]\n lo, hi = betastar(d, N, rho, c0, lq)\n e = eps_of(lo, hi, N, rho, lq)\n print(f"rho={mp.nstr(rho,2)}, s={s}: beta* in {sci(lo, hi, 7)};"\n f" eps in [{mp.nstr(mpf(e.a),4)}, {mp.nstr(mpf(e.b),4)}]")\n assert 0 < mpf(e.a) and mpf(e.b) < 0.05\nlq = lqs[(5, \'isl\')] - H * iv.log(iv.mpf(10) ** 30)\nlo, hi = betastar(d, N, mpf(\'1e-8\'), c0, lq)\nprint(f"rho=1e-8, s=5, Gamma=1e30: beta* in {sci(lo, hi, 7)}")\nprint("ratio beta*_SU(3)/beta*_SU(2,paper C0) at rho=1e-8, s=1:")\nlo3, hi3 = betastar(8, 3, mpf(\'1e-8\'), c0, lqs[(1, \'isl\')])\nlo2, hi2 = betastar(3, 2, mpf(\'1e-8\'), c0p, lqs[(1, \'isl\')])\nprint(f" {mp.nstr(lo3/hi2, 6)} .. {mp.nstr(hi3/lo2, 6)}")\n\nprint()\nprint("== (E) SU(3): island threshold at scale j (s=5, rho=1e-8) ==")\ndef Hj(j):\n return 8 ** 4 if j <= 2 else 9 ** 4\nworst = mpf(0)\nfor j in range(1, 13):\n Mj = (17 * 2 ** j - 4) ** 4\n lqj = logqstar((4 * 5 + 3) ** 4 - 1, Mj, Hj(j))\n rho0 = mpf(\'1e-8\') / (mpf(\'1.01\') * mpf(\'1.023\') * 4 ** j)\n # rho0 is rounded: use the interval of the exact quotient\n rho0_iv = iv.mpf(\'1e-8\') / (iv.mpf(\'1.01\') * iv.mpf(\'1.023\') * 4 ** j)\n lo, hi = betastar(8, 3, mpf(rho0_iv.b), c0, lqj)\n # the root is decreasing in rho, so the upper endpoint of rho gives a\n # lower bound; recompute with rho0_iv.a for the upper bound\n lo2_, hi2_ = betastar(8, 3, mpf(rho0_iv.a), c0, lqj)\n r = hi2_ / mpf(16) ** j\n worst = max(worst, r)\n if j <= 3:\n print(f"j={j}: beta*_j in {sci(lo, hi2_, 5)}")\nprint(f"max_j<=12 16^-j beta*_j <= {mp.nstr(worst, 5)}")\n\nprint()\nprint("== (F) SU(3): two islands, layer bound and the window ==")\nr3 = 3\nc3 = iv.mpf(15000) * iv.sqrt(r3) # > dim SU(3) = 8\nc6 = iv.mpf(681000) * 8 * c3 ** 2\nrho_max = 1 / (iv.mpf(2758) * 195 * 400000 * c3)\nprint(f"c3 = 1.5e4 sqrt3 in [{mp.nstr(mpf(c3.a),8)}, {mp.nstr(mpf(c3.b),8)}]")\nprint(f"c6 = 6.81e5*8*c3^2 in [{mp.nstr(mpf(c6.a),6)}, {mp.nstr(mpf(c6.b),6)}]")\nprint(f"hypothesis (a): rho <= 1/(2758*195*4e5*c3) in"\n f" [{mp.nstr(mpf(rho_max.a),6)}, {mp.nstr(mpf(rho_max.b),6)}]")\nbmin = 480 * 3 * c6\nprint(f"hypothesis (b): beta_W >= 480 N c6 = [{mp.nstr(mpf(bmin.a),6)},"\n f" {mp.nstr(mpf(bmin.b),6)}]")\nrho = mpf(\'1.78e-16\')\nassert rho < mpf(rho_max.a)\nfor s in (1, 5):\n lq = lqs[(s, \'join\')]\n lo, hi = betastar(8, 3, rho, c0, lq)\n print(f"rho=1.78e-16, s={s}, joining distance 2s+8: beta* in {sci(lo, hi, 7)}")\n assert lo > mpf(bmin.b)\n if s == 1:\n bst = iv.mpf([lo, hi])\nprint("so hypothesis (b) holds at every beta_W >= beta*")\n# c2 of the window theorem at s=1, theta=0, kappa=2 alpha_G\nalphaG = iv.mpf(\'2.5e-4\')\nr = 43 * iv.mpf(rho)\nLam2 = iv.mpf(\'66.0001\') * bst + iv.mpf(8) / 3 * iv.mpf(\'4.65e6\')\ns = 1\nc2 = (960 * 3 / bst) * Lam2 ** 2 * r ** 2 * 45 * (2 * s + 12) ** 2 * \\\n (2 * s + 7) ** 2 * iv.exp(2 * alphaG * (2 * s + 14))\nprint(f"Lambda2bar(beta*) <= {mp.nstr(mpf(Lam2.b), 6)}")\nprint(f"c2 (s=1, theta=0) <= 10^{mp.nstr(mpf(iv.log(c2).b) / math.log(10), 5)}")\n# SU(2) value for comparison, paper\'s numbers\nrho2 = iv.mpf(\'2.17e-16\')\nlo, hi = betastar(3, 2, mpf(\'2.17e-16\'), c0p, lqs[(1, \'join\')])\nb2 = iv.mpf([lo, hi])\nLam22 = iv.mpf(\'99.0001\') * b2 + iv.mpf(\'4.65e6\')\nc22 = (1920 / b2) * Lam22 ** 2 * (43 * rho2) ** 2 * 45 * 14 ** 2 * 9 ** 2 * \\\n iv.exp(2 * alphaG * 16)\nprint(f"check SU(2): beta*={sci(lo, hi, 6)}, c2 <= 10^"\n f"{mp.nstr(mpf(iv.log(c22).b) / math.log(10), 5)} (paper: 10^22.13)")\n\nprint()\nprint("== (G) the threshold in the other groups (rho = 1e-8 rho_G, s = 1,5) ==")\nprint("group rho_G s=1: beta* eps s=5: beta*")\nfor name, d, N, kap, rG in groups:\n rho = mpf(\'1e-8\') * mpf(rG)\n out = []\n for s in (1, 5):\n lo, hi = betastar(d, N, rho, c0s[name], lqs[(s, \'isl\')])\n e = eps_of(lo, hi, N, rho, lqs[(s, \'isl\')])\n assert mpf(e.a) > 0\n out.append((lo, hi, e))\n print(f"{name:7s} {rG:5s} {mp.nstr(out[0][1],5):12s} eps<{mp.nstr(mpf(out[0][2].b),3):9s}"\n f" {mp.nstr(out[1][1],5)}")\n\nprint()\nprint("== (H) the general formula ==")\nprint("beta*_G = 8 N |log q*| rho^-2 (1+eps), eps = (2 d log beta*_G + 6 C0(G))/|log q*|,")\nprint("an identity at the root; table (G) gives the values of eps.")\n\nprint()\nprint("== (I) group constants of the layer bound, the mixed derivatives and the site ==")\nprint("c3 = max(1.5e4 sqrt N, d), c6 = 6.81e5 d c3^2; (b): beta_W >= 480 N c6;")\nprint("(a) at r=43 rho, eta=92 rho: rho <= 1/(2758*7.8e7*c3);")\nprint("Lambda2 <= (2/N) 99.0001 beta_W + (d/3) 4.65e6;")\nprint("site: C <= 197 beta_W + a_G (non-path), 87 beta_W + b_G (inside),")\nprint(" a_G = 24 sqrt N * 64.94 (d/3) sqrt(kappa) + 1.1986,")\nprint(" b_G = 24 sqrt N * 32.47 (d/3) sqrt(kappa) + 0.5993; delta_G = kappa/3")\nprint("group c3 (b) beta_W >= (a) rho <= cW coeff cpsi a_G b_G")\nfor name, d, N, kap, rG in groups:\n c3 = max(iv.mpf(15000) * iv.sqrt(N), iv.mpf(d)) if d < 15000 * math.sqrt(N) else iv.mpf(d)\n c6 = iv.mpf(681000) * d * c3 ** 2\n bmin = 480 * N * c6\n rmax = 1 / (iv.mpf(2758) * 195 * 400000 * c3)\n cw = iv.mpf(\'99.0001\') * 2 / N\n cp = iv.mpf(\'4.65e6\') * d / 3\n k = ivq(Fr(kap))\n aG = 24 * iv.sqrt(N) * iv.mpf(\'64.94\') * d / 3 * iv.sqrt(k) + iv.mpf(\'1.1986\')\n bG = 24 * iv.sqrt(N) * iv.mpf(\'32.47\') * d / 3 * iv.sqrt(k) + iv.mpf(\'0.5993\')\n print(f"{name:7s} {mp.nstr(mpf(c3.b),6):10s} {mp.nstr(mpf(bmin.b),4):14s} "\n f"{mp.nstr(mpf(rmax.a),4):12s} {mp.nstr(mpf(cw.b),7):10s} "\n f"{mp.nstr(mpf(cp.b),4):10s} {mp.nstr(mpf(aG.b),6):9s} {mp.nstr(mpf(bG.b),6)}")\nprint("check SU(2): a_G < 2206 - 0 and b_G < 1103 (the constants of Theorem (site))")\naG2 = 24 * iv.sqrt(2) * iv.mpf(\'64.94\') + iv.mpf(\'1.1986\')\nbG2 = 24 * iv.sqrt(2) * iv.mpf(\'32.47\') + iv.mpf(\'0.5993\')\nassert mpf(aG2.b) < 2206 and mpf(bG2.b) < 1103\nprint(f" a_SU(2) <= {mp.nstr(mpf(aG2.b),7)}, b_SU(2) <= {mp.nstr(mpf(bG2.b),7)}")\nprint("Haar part of the layer bound: kappa_G/3 * 1e-3 * (1+1e-5) <= 0.84 needs kappa_G <= 2519;")\nfor name, d, N, kap, rG in groups:\n assert Fr(kap) * Fr(1, 3000) * Fr(100001, 100000) <= Fr(84, 100)\nprint(" holds for every group of the table, and for SU(N) with N <= 5038.")\n', 'd5/island_radius.py': '"""Certified island thresholds (thm:islandthreshold, thm:islandscales, thm:islandswide) and k_*.\nInterval arithmetic: mpmath.iv. Usage: python3 island_radius.py\nEvery root beta* is certified by g(lo)>0>g(hi) with lo>96/rho0^2 (g decreasing there)."""\nfrom mpmath import mp, iv, mpf, findroot, log as mlog\nmp.dps = 40; iv.dps = 40\nI = lambda x: iv.mpf(x)\nC0 = I(1)/2 + I(2)/3*iv.log(24*iv.pi**3)\nC1 = C0 + iv.log(I(12800))/6\ndef Delta(s): return I((4*s+3)**4 - 1)\ndef logq(M, H, s):\n return -I(H)*(iv.log(I(2)) + 2*iv.log(Delta(s))) - (1 + iv.log(I(M)) + iv.log(I(H)))\ndef g(beta, rho0, lq): # f(beta)-log q*\n b = I(beta); return 6*(iv.log(b)+C0) - b*I(rho0)**2/16 - lq\ndef root(rho0, lq):\n lqm = mpf(lq.b); r0 = mpf(rho0)\n fm = lambda b: 6*(mlog(b)+mpf(C0.b)) - b*r0**2/16 - lqm\n a, c = 96/r0**2, 64*abs(lqm)/r0**2 # fm(a)>0>fm(c); fm decreasing on [a,c]\n assert fm(a) > 0 and fm(c) < 0\n for _ in range(200):\n m = (a*c)**0.5\n if fm(m) > 0: a = m\n else: c = m\n b = (a*c)**0.5\n lo, hi = b*(1-mpf(10)**-12), b*(1+mpf(10)**-12)\n assert lo > 96/r0**2\n assert g(lo, I(rho0), lq).a > 0 and g(hi, I(rho0), lq).b < 0, "not certified"\n return lo, hi\ndef Hj(j): return 8**4 if j <= 2 else 9**4\ndef Mj(j): return (17*2**j - 4)**4\ndef betastar_scale(rho, j, s):\n rho0 = I(rho)/(I(\'1.01\')*I(\'1.023\')*I(4)**j)\n rho0m = mpf(rho0.a) # lower end of rho0 -> larger root: upper bound side\n lq = logq(Mj(j), Hj(j), s)\n # certify with both ends of rho0 interval: take root for rho0.a (largest beta) and rho0.b\n lo1, hi1 = root(mpf(rho0.b), lq); lo2, hi2 = root(mpf(rho0.a), lq)\n return min(lo1, lo2), max(hi1, hi2)\ndef betastar_one(rho, s):\n return root(mpf(rho), logq(11**4, 6**4, s))\ndef kstar(beta):\n b = I(beta); rho = iv.sqrt(96*(iv.log(b)+C1)/b)\n t = iv.log(I(\'1e-4\')/(I(\'1.01\')*rho))/iv.log(I(4))\n import math\n fa, fb = math.floor(mpf(t.a)), math.floor(mpf(t.b))\n assert fa == fb, ("k* ambiguous", beta)\n return fa\ndef run(rho, s, jmax_scan, logb_lo, logb_hi, npts, label):\n print(f"=== {label}: rho={rho}, s={s}")\n b0 = betastar_one(rho, s); print(f"one scale beta*({rho},{s}) in [{mp.nstr(b0[0],6)}, {mp.nstr(b0[1],6)}]")\n bs = [b0]\n worst = mpf(0)\n for j in range(1, jmax_scan+1):\n lo, hi = betastar_scale(rho, j, s); bs.append((lo, hi))\n c = hi/mpf(16)**j; worst = max(worst, c)\n if j <= 4 or j == jmax_scan: print(f" j={j}: beta*_j in [{mp.nstr(lo,6)}, {mp.nstr(hi,6)}], 16^-j beta*_j <= {mp.nstr(c,6)}")\n assert lo/bs[-2][1] >= 16 if j >= 2 else True\n print(f" max_j<= {jmax_scan} of 16^-j beta*_j <= {mp.nstr(worst,6)}")\n hist = {}\n for i in range(npts):\n lb = mpf(logb_lo) + (mpf(logb_hi)-logb_lo)*i/(npts-1)\n beta = mpf(10)**lb\n jm = -1\n for j,(lo,hi) in enumerate(bs):\n if beta >= hi: jm = j\n elif beta >= lo: raise Exception("ambiguous j_max")\n else: break\n assert jm < jmax_scan, "scan more scales"\n if jm < 0: continue\n d = kstar(beta) - jm\n hist[d] = hist.get(d, 0) + 1\n print(f" k*-j_max over {npts} couplings 10^{logb_lo}..10^{logb_hi} (skipping beta0>f(hi)\n for _ in range(200):\n m=(lo+hi)/2\n if f(m)>0: lo=m\n else: hi=m\n b=lo\n return b, logqstar, D\nfor rho,s in ((mpf(\'1e-8\'),1),(mpf(\'1e-8\'),5),(mpf(\'1e-9\'),1)):\n for join in (2*s+1, 2*s+7):\n b,lq,D=beta_star(rho,s,join)\n print(f"rho={rho} s={s} join={join} Delta={int(D)} log q*={float(lq):.1f} beta*={float(b):.4e}")\nrho_c=mpf(\'6.0e-13\')/(92+49*43)\nprint(f"rho_c={float(rho_c):.4e}")\nfor s in (1,5):\n b,lq,D=beta_star(rho_c,s,2*s+8)\n print(f"rho=rho_c s={s} join={2*s+8} log q*={float(lq):.1f} beta*={float(b):.4e}")\n', 'd5/island_window.py': '"""Constants of Theorem thm:islandwindow (the island sums in a window).\n\nEvery inequality used in the statement is checked in interval arithmetic\n(mpmath.iv): a claim "X <= c" is accepted only when the upper end of the\ninterval enclosing X is <= c. Large and small numbers are handled through\ntheir natural or decimal logarithms.\n"""\nfrom mpmath import iv, mp\n\niv.dps = 60\nmp.dps = 60\n\nH, M = 1296, 14641 # overlap 6^4 and witness box 11^4\nalphaG = iv.mpf(1) / 4000 # 2.5e-4\nrho = iv.mpf(217) / iv.mpf(10) ** 18 # 2.17e-16\nr = 43 * rho\nC0 = iv.mpf(1) / 2 + iv.mpf(2) / 3 * iv.log(24 * iv.pi ** 3)\nLN10 = iv.log(10)\n\ndef log10(x):\n return iv.log(x) / LN10\n\nchecks = []\nstated = []\nclaims = {}\nlog10G0_s = {}\ndef check(name, ok):\n checks.append((name, bool(ok)))\n print(("PASS " if ok else "FAIL ") + name)\n\ndef up(x): # upper end of an interval, as a float string\n return mp.nstr(mp.mpf(x._mpi_[1]), 14)\ndef lo(x):\n return mp.nstr(mp.mpf(x._mpi_[0]), 14)\n\ndef sigma(kappa):\n x = iv.exp(-kappa)\n return 1 + 64 * x * (1 + 4 * x + x * x) / (1 - x) ** 4 + 16 * x / (1 - x) ** 2\n\nprint("rho in", lo(rho), up(rho), " r = 43 rho, eta = 92 rho")\nprint("eta + 62 r = 2758 rho <= 6.0e-13 :", up(2758 * rho))\ncheck("hypothesis (a): 2758 rho <= 6.0e-13", (2758 * rho).b <= 6e-13)\ncheck("Lemma lambdatwo: eta + 30 r = 1382 rho <= 6.0e-13", (1382 * rho).b <= 6e-13)\n\nfor s in (1, 5):\n print("\\n================ s =", s, "================")\n N = (4 * s + 17) ** 4 - 1\n logqstar = -(H * (iv.log(2) + 2 * iv.log(N)) + 1 + iv.log(M * H))\n print("N_s =", N, " |log q*| in [", lo(-logqstar), ",", up(-logqstar), "]")\n\n def g_pt(b): # point version for bisection\n b = mp.mpf(b)\n rh = mp.mpf(217) / mp.mpf(10) ** 18\n c0 = mp.mpf(1) / 2 + mp.mpf(2) / 3 * mp.log(24 * mp.pi ** 3)\n lq = -(H * (mp.log(2) + 2 * mp.log(N)) + 1 + mp.log(M * H))\n return 6 * (mp.log(b) + c0) - b * rh ** 2 / 16 - lq\n a, b = mp.mpf(96) / (mp.mpf(217) / mp.mpf(10) ** 18) ** 2, mp.mpf(10) ** 40\n for _ in range(400):\n m = (a + b) / 2\n if g_pt(m) > 0: a = m\n else: b = m\n blo, bhi = iv.mpf(a * (1 - mp.mpf(10) ** -20)), iv.mpf(b * (1 + mp.mpf(10) ** -20))\n def g(beta):\n return 6 * (iv.log(beta) + C0) - beta * rho ** 2 / 16 - logqstar\n check("s=%d: g(beta_lo) > 0 > g(beta_hi), beta_lo > 96/rho^2" % s,\n g(blo).a > 0 and g(bhi).b < 0 and (blo - 96 / rho ** 2).a > 0)\n print("beta* in [", lo(blo), ",", up(bhi), "]")\n check("s=%d: beta* > 112/rho^2 (monotonicity of Lambda^2 e^f / beta)" % s,\n (blo - 112 / rho ** 2).a > 0)\n # thm:islandthreshold(i): A <= (2 N^2)^{-H} at beta*, i.e. x = N^2 A^{1/H} <= 1/2\n log10Mq = log10(iv.mpf(M)) + logqstar / LN10\n log10A = log10(iv.e * M * H) + logqstar / LN10\n print("log10(M q*) <=", up(log10Mq), " log10 A* <=", up(log10A))\n logx = 2 * iv.log(N) + (1 + iv.log(M * H) + logqstar) / H\n print("x = N^2 A*^{1/H}: log x in", lo(logx), up(logx), " (log 1/2 =", mp.nstr(-mp.log(2), 12), ")")\n check("s=%d: x <= 1/2 at beta*" % s, (logx + iv.log(2)).b <= 1e-40)\n # G_0 = H (M q* + A* u/(1-u)), u = N^{2H} A* = x^H <= 2^{-H}\n u = iv.mpf(2) ** (-H)\n log10G0 = log10(iv.mpf(H)) + log10(iv.mpf(10) ** log10Mq + iv.mpf(10) ** log10A * u / (1 - u))\n print("log10 G_0 <=", up(log10G0))\n log10G0_s[s] = log10G0\n for theta, label in ((iv.mpf(0), "0"), (iv.mpf(1) / 2, "1/2")):\n kappa = 2 * (1 - theta) * alphaG\n sk, sk2 = sigma(kappa), sigma(kappa / 2)\n print("--- vartheta =", label, " kappa =", lo(kappa))\n print("sigma(kappa) in [", lo(sk), ",", up(sk), "] sigma(kappa/2) <=", up(sk2))\n # annealed island mass: paper\'s bound at Gamma=1 vs G_0\n paper = 2 * sk / iv.mpf(N) ** 2\n print("prop:islandmass(ii) at Gamma=1 per |J|:", lo(paper), up(paper))\n print("new mean bound G_0 sigma(kappa): log10 <=", up(log10G0 + log10(sk)))\n # c_2 at beta_hi (c_2 increases with beta)\n Lam = iv.mpf(\'99.0001\') * bhi + iv.mpf(\'4.65e6\')\n c2 = 1920 * Lam ** 2 * r ** 2 / bhi * 45 * (2 * s + 12) ** 2 * (2 * s + 7) ** 2 \\\n * iv.exp(kappa * (2 * s + 14))\n print("log10 c_2(beta*) <=", up(log10(c2)))\n check("s=%d theta=%s: log10 c_2 <= %s" % (s, label, {1: "22.13", 5: "23.14"}[s]),\n log10(c2).b <= {1: 22.13, 5: 23.14}[s])\n check("s=%d theta=%s: log10 G_0 sigma(kappa) <= %s" % (s, label, {1: "-14082.3", 5: "-16632.6"}[s]),\n (log10G0 + log10(sk)).b <= {1: -14082.3, 5: -16632.6}[s])\n for R in (2 * s + 13, int(mp.ceil(2 * mp.mpf(10) ** 8 / (1 - mp.mpf(theta.a))))):\n near = log10(iv.mpf(11) ** 4) + 4 * log10(iv.mpf(2 * R + 1)) + 2 * log10Mq\n if R == 2 * s + 13:\n ltau = log10(sk)\n else:\n ltau = -kappa * R / 2 / LN10 + log10(sk2)\n farpref = log10Mq + log10(c2) + log10G0 + ltau # times 1/sigma\n print("R = %d: log10 near/|W| <= %s ; log10 far/|W| <= %s - log10(sigma)"\n % (R, up(near), up(farpref)))\n for lsig in (-100, -1000):\n tot = up(log10(10 ** near + 10 ** (farpref - lsig)))\n print(" sigma = 1e%d: log10 eps/|W| <= %s" % (lsig, tot))\n claims[(s, label, R, lsig)] = (near, farpref - lsig)\n if R != 2 * s + 13:\n check("s=%d theta=%s R=%d sigma=1e%d: far <= near"\n % (s, label, R, lsig), (farpref - lsig - near).b <= 0)\n # reference: decimal statements used in the theorem\n if s == 1:\n check("s=1: log10(M q*) <= -14102.4", log10Mq.b <= -14102.4)\n check("s=1: log10 A* <= -14098.8", log10A.b <= -14098.8)\n check("s=1: log10 G_0 <= -14099.3", log10G0.b <= -14099.3)\n if s == 5:\n check("s=5: log10(M q*) <= -16652.79", log10Mq.b <= -16652.79)\n check("s=5: log10 G_0 <= -16649.6", log10G0.b <= -16649.6)\n stated.append((s, blo, bhi))\n\nprint("\\n================ statements of the theorem ================")\nfor (s, blo_, bhi_) in stated:\n print("s=%d: beta* in [%s, %s]" % (s, lo(blo_), up(bhi_)))\ncheck("s=1: beta* in [1.1220e37, 1.1221e37]", stated[0][1].a >= 1.1220e37 and stated[0][2].b <= 1.1221e37)\ncheck("s=5: beta* in [1.3216e37, 1.3217e37]", stated[1][1].a >= 1.3216e37 and stated[1][2].b <= 1.3217e37)\ndef tot(k):\n n, f = claims[k]\n return log10(iv.mpf(10) ** n + iv.mpf(10) ** f)\ncheck("s=1, theta=0, R=15: near <= 1e-28194 |W|", claims[(1, "0", 15, -100)][0].b <= -28194)\ncheck("s=1, theta=0, R=15: far <= 1e-28163.8 |W| / sigma", (claims[(1, "0", 15, -100)][1] - 100).b <= -28163.8)\ncheck("s=1, theta=0, R=2e8, sigma>=1e-1000: eps <= 1e-28166 |W|", tot((1, "0", 200000000, -1000)).b <= -28166)\ncheck("s=1, theta=1/2, R=4e8, sigma>=1e-1000: eps <= 1e-28165 |W|", tot((1, "1/2", 400000000, -1000)).b <= -28165)\ncheck("s=5, theta=0, R=2e8, sigma>=1e-1000: eps <= 1e-33267 |W|", tot((5, "0", 200000000, -1000)).b <= -33267)\ncheck("s=1: G_0 sigma(2 alpha_G) <= 1e-14083.5", (log10G0_s[1] + log10(sigma(2 * alphaG))).b <= -14083.5)\ncheck("s=5: G_0 sigma(2 alpha_G) <= 1e-16633.8", (log10G0_s[5] + log10(sigma(2 * alphaG))).b <= -16633.8)\ncheck("|W| <= 1e28000 gives eps <= 1e-166 (s=1, theta=0)", (tot((1, "0", 200000000, -1000)) + 28000).b <= -166)\n# the paper\'s value 1.13e37 of cor:twoislands corresponds to rho = 2.16e-16\nrho2 = iv.mpf(216) / iv.mpf(10) ** 18\nfor s, val in ((1, 1.13e37), (5, 1.33e37)):\n N = (4 * s + 17) ** 4 - 1\n lq = -(H * (iv.log(2) + 2 * iv.log(N)) + 1 + iv.log(M * H))\n def g2(beta): return 6 * (iv.log(beta) + C0) - beta * rho2 ** 2 / 16 - lq\n print("rho=2.16e-16, s=%d: g(%.4g) = %s, g(%.4g) = %s" % (s, val * 0.995, lo(g2(iv.mpf(val * 0.995))), val * 1.005, up(g2(iv.mpf(val * 1.005)))))\nprint("\\nsigma(5e-4) (paper: 6.144e15):", lo(sigma(2 * alphaG)), up(sigma(2 * alphaG)))\nprint("\\nall checks passed:", all(ok for _, ok in checks), "(%d checks)" % len(checks))\n', 'd5/islands.py': '"""Order-of-magnitude thresholds for ISLANDS.md (crude; see the note).\n\nWindow of side n0 lattice units (blocks of side 2): m = (n0/2)^4 blocks.\nLocal calm-fibre bound (Prop L): exponent 73 m, n_P <= 576 m, K = 4.8e-18.\nCalm exterior threshold for the window: rho_c = K/(8 n_P) (Cor. calmexterior).\nRarity (RARE.md): log q(rho) = -beta rho^2/16 + 6 log beta + 24.7 + log(6e*80).\nIsland + collar cost per site: (4.5 beta * C_G)^(4*81).\n"""\nfrom mpmath import mp, mpf, log, e\nmp.dps = 40\nK = mpf(\'4.8e-18\'); CG = mpf(\'3e13\')\nfor alpha in [mpf(\'0.9\'), mpf(\'0.5\')]:\n n0 = 17*CG/alpha\n m = (n0/2)**4\n nP = 576*m\n # (1) off-chart error in the window small: (3/4) lam K^2 >= 73 m log(3e8 nP^1.5/K^3) + log(lam*4 n0^4) + 10\n L1 = 73*m*log(mpf(\'3e8\')*nP**mpf(\'1.5\')/K**3)\n lam1 = 4*(L1 + 500)/(3*K**2); b1 = 4*lam1\n # (2) windows calm with tails: q(rho_c) * (4.5 beta CG)^(324) < 1/2\n rho = K/(8*nP)\n f = lambda lb: -mp.e**lb*rho**2/16 + 6*lb + mpf(\'24.7\') + log(6*e*80) + 324*(log(mpf(\'4.5\'))+lb+log(CG)) + log(2)\n lo, hi = mpf(1), mpf(2000)\n for _ in range(200):\n mid=(lo+hi)/2\n lo, hi = (mid, hi) if f(mid) > 0 else (lo, mid)\n lb = hi\n print(f\'alpha={alpha}: n0={mp.nstr(n0,3)} m={mp.nstr(m,3)} beta for small off-chart error >= {mp.nstr(b1,3)}\'\n f\' rho_c={mp.nstr(rho,3)} beta for calm-window islands >= {mp.nstr(mp.e**lb,3)}\')\n', 'd5/lambda2_constants.py': '"""Constants of lem:lambdatwo (the bound on Lambda_2 of prop:layercross, G = SU(2)).\n\nPart 1 checks by enumeration the combinatorial facts used in the proof.\nPart 2 evaluates the analytic constants (mpmath, 40 digits; printed values\nare rounded up where they are upper bounds).\nPart 3 evaluates Delta of cor:twoislands and the width that makes Delta <= 1.\n"""\nimport itertools\nfrom mpmath import mp, mpf, sqrt, sin, exp, log, ceil\n\nmp.dps = 40\nD = 4\nE = [tuple(1 if i == m else 0 for i in range(D)) for m in range(D)]\nZERO = (0,) * D\n\n\ndef add(a, b): return tuple(x + y for x, y in zip(a, b))\ndef sub(a, b): return tuple(x - y for x, y in zip(a, b))\ndef off(x): return tuple(c % 2 for c in x)\ndef blk(x): return tuple(c // 2 for c in x)\n\n\ndef is_tree(l):\n x, m = l\n o = off(x)\n return o[m] == 0 and all(o[n] == 0 for n in range(m + 1, D))\n\n\ndef is_path(l):\n x, m = l\n return off(x) == E[m]\n\n\ndef kind(l):\n if is_tree(l): return \'tree\'\n if is_path(l): return \'path\'\n return \'private\' if off(l[0])[l[1]] == 1 else \'inside\'\n\n\ndef path_link(k):\n y, m = k\n return (add(tuple(2 * c for c in y), E[m]), m)\n\n\ndef args(k):\n """non-path links of the fourteen paths of nonzero offset of the pair k"""\n y, m = k\n base = tuple(2 * c for c in y)\n res = []\n for o in itertools.product((0, 1), repeat=D):\n if o in (ZERO, E[m]): continue\n x = add(base, o)\n for l in ((x, m), (add(x, E[m]), m)):\n assert not is_path(l)\n if l not in res: res.append(l)\n return res\n\n\ndef mult(k, g):\n """number of paths of nonzero offset of k that contain g"""\n y, m = k\n base = tuple(2 * c for c in y)\n n = 0\n for o in itertools.product((0, 1), repeat=D):\n if o in (ZERO, E[m]): continue\n x = add(base, o)\n n += g in ((x, m), (add(x, E[m]), m))\n return n\n\n\ndef plaqs(l):\n x, m = l\n out = []\n for n in range(D):\n if n == m: continue\n mu, nu = min(m, n), max(m, n)\n for b in (x, sub(x, E[n])):\n out.append(frozenset([(b, mu), (add(b, E[mu]), nu), (add(b, E[nu]), mu), (b, nu)]))\n return out\n\n\ndef pairs_of(g):\n x, m = g\n y = blk(x)\n return [k for k in ((y, m), (sub(y, E[m]), m)) if g in args(k)]\n\n\ndef part1():\n print(\'Part 1: combinatorics (enumeration over all link types)\')\n offs = list(itertools.product((0, 1), repeat=D))\n nonpath = [(o, m) for o in offs for m in range(D) if kind((o, m)) in (\'private\', \'inside\')]\n print(\' non-path active links per block:\', len(nonpath),\n \'(private\', sum(kind(g) == \'private\' for g in nonpath), \', inside\',\n sum(kind(g) == \'inside\' for g in nonpath), \')\')\n for m in range(D):\n a = args((ZERO, m))\n assert len(a) == 21 and sum(kind(l) == \'private\' for l in a) == 7\n print(\' each pair: 21 arguments, 7 private non-path, 14 inside (tree ones included)\')\n for g in nonpath:\n assert len(set(plaqs(g))) == 6\n K = pairs_of(g)\n if kind(g) == \'private\':\n assert len(K) == 1 and mult(K[0], g) == 2\n else:\n assert len(K) == 2 and all(mult(k, g) == 1 for k in K)\n assert path_link(K[0])[1] == path_link(K[1])[1]\n print(\' private: one pair, two paths; inside: two pairs (parallel path links), one path each\')\n maxpl = 0\n for o in itertools.product(range(4), repeat=D):\n for m in range(D):\n for p in plaqs((o, m)):\n maxpl = max(maxpl, sum(is_path(l) for l in p))\n print(\' largest number of path links on one plaquette:\', maxpl)\n for m in range(D):\n pl = path_link((ZERO, m))\n two = 0\n for p in plaqs(pl):\n npath = sum(is_path(l) for l in p)\n nnon = sum(kind(l) in (\'private\', \'inside\') for l in p)\n assert npath + nnon <= 4 and nnon <= 2\n two += npath == 2\n assert two == 3\n print(\' each path link: six plaquettes, three of them with a second path link,\'\n \' at most two non-path links on each\')\n worst = 0\n for g in nonpath:\n tot = sum(sum(is_path(l) for l in p) for p in plaqs(g))\n worst = max(worst, tot)\n print(\' largest number of path links on the six plaquettes of a non-path link:\', worst)\n # exact Schur row sum of the Wilson part, all path links solved, gamma_P = 1\n gP, gI = 1.0, 0.5\n gam = {\'private\': gP, \'inside\': gI, \'tree\': 0.0}\n best = 0\n for o in itertools.product(range(2), repeat=D):\n for m in range(D):\n g = (o, m)\n if kind(g) not in (\'private\', \'inside\'): continue\n K = pairs_of(g)\n P = set(plaqs(g))\n for k in K: P |= set(plaqs(path_link(k)))\n T = 0.0\n for p in P:\n A = 1.0 if g in p else 0.0\n S = 0.0\n for l in p:\n if is_path(l):\n k = (blk(sub(l[0], E[l[1]])), l[1])\n if k in K: A += gam[kind(g)]\n S += sum(gam[kind(h)] for h in args(k) if h != g)\n elif l != g:\n S += 0.0 if is_tree(l) else 1.0\n T += A * S\n best = max(best, T)\n print(\' exact value of the Wilson row sum at gamma_P = 1 (not used in the proof): %.1f\' % (best / 2))\n print()\n\n\ndef constants(r, kappa, label):\n r = mpf(r); kappa = mpf(kappa)\n s2 = sqrt(2)\n thZ = 16 * s2 * r\n m1 = (thZ / 2) / sin(thZ / 2)\n eZ = (m1 - 1) + m1 * thZ / 2\n thX = 14 * s2 * r\n eX = (1 - sin(thX / 2) / (thX / 2)) + thX / 2\n eA = 2 * s2 * r\n epsT = eZ + eA + eX\n m = 8 / (1 - 7 * epsT)\n gP = m1 / (1 - 7 * epsT)\n sig = mpf(1) / 2\n MG = -log(2 - exp(sig))\n B2 = MG / ((sig - 16 * r) / 2) ** 2\n B3 = MG / ((sig - 16 * r) / 3) ** 3\n X2 = m * B2 / 16 * (14 * gP ** 2 + 4 * gP + 1)\n C2 = exp(14 * r) * gP ** 2 + X2\n M1 = B2 * (14 * gP + 2) / 16\n M2 = B3 * (14 * gP ** 2 + 4 * gP + 1) / 16 + mpf(14) / 16 * B2 * X2\n L = 3 * m * M2 + 3 * m ** 2 * M1 ** 2\n wil = 9 + 27 * gP + 63 * gP ** 2\n kap = kappa / 2 * 240 * C2\n cW = wil + kap\n cpsi = 40 * L\n print(\'Part 2: constants,\', label)\n for name, val in [(\'r\', r), (\'kappa\', kappa), (\'m_1\', m1), (\'e_Z\', eZ), (\'e_X\', eX),\n (\'e_A\', eA), (\'eps_T\', epsT), (\'m = 8/(1-7eps_T)\', m), (\'gamma_P\', gP),\n (\'M_G\', MG), (\'B_2\', B2), (\'B_3\', B3), (\'X_2\', X2), (\'C_2\', C2),\n (\'M_1\', M1), (\'M_2\', M2), (\'L\', L),\n (\'9+27g+63g^2\', wil), (\'kappa term\', kap), (\'c_W\', cW), (\'c_psi\', cpsi)]:\n print(\' %-18s %s\' % (name, mp.nstr(val, 12)))\n print()\n return cW, cpsi\n\n\ndef nblocks(d):\n return (2 * d + 1) ** 4 - (2 * d - 1) ** 4\n\n\ndef part3(cW, cpsi, beta, rho, s, label):\n beta = mpf(beta); rho = mpf(rho)\n r = 43 * rho\n eta = 92 * rho\n aG = mpf(\'2.5e-4\')\n nx = 45 * (nblocks(s + 1) + nblocks(s + 2)) + 17 * nblocks(s + 3)\n Lam2 = beta * cW + cpsi\n pre = 1920 / beta * Lam2 ** 2 * r ** 2 * nx\n wmin = 2 * s + 8 + log(pre) / (2 * aG)\n print(\'Part 3: Delta of cor:twoislands,\', label)\n print(\' beta_W =\', mp.nstr(beta, 6), \' s =\', s, \' rho =\', mp.nstr(rho, 6),\n \' r = 43 rho =\', mp.nstr(r, 6), \n \' eta+30r =\', mp.nstr(eta + 30 * r, 6))\n print(\' single-block islands: N_{s+1},N_{s+2},N_{s+3} =\',\n nblocks(s + 1), nblocks(s + 2), nblocks(s + 3), \' n_x = n_y =\', nx)\n print(\' Lambda_2 <=\', mp.nstr(Lam2, 8), \' beta_W r^2 =\', mp.nstr(beta * r ** 2, 8))\n print(\' Delta <= %s * exp(-2 alpha_G (w-2s-8))\' % mp.nstr(pre, 6))\n print(\' ln(prefactor) =\', mp.nstr(log(pre), 8))\n print(\' Delta <= 1 for w >=\', mp.nstr(wmin, 8), \' i.e. w >=\', int(ceil(wmin)))\n print(\' each factor e in beta_W/beta* adds\', mp.nstr(1 / (2 * aG), 6), \'layers;\',\n \'islands of a and b blocks add 1000 ln(ab) layers at most\')\n print()\n\n\nif __name__ == \'__main__\':\n part1()\n constants(\'8e-5\', \'1e-8\', \'general lemma: r <= 8e-5, kappa <= 1e-8\')\n rcal = mpf(\'6.0e-13\') / 62\n cW, cpsi = constants(rcal, \'6.0e-13\', \'hypothesis (a) of thm:layerbound: r <= 6.0e-13/62, kappa <= 6.0e-13\')\n part3(cW, cpsi, \'1.13e37\', \'2.17e-16\', 1, \'at the threshold of cor:twoislands, s = 1\')\n part3(cW, cpsi, \'1.33e37\', \'2.17e-16\', 5, \'at the threshold of cor:twoislands, s = 5\')\n', 'd5/largefield_constants.py': '"""Constants of the large-field block (largefield.tex), certified.\n\nReal constants are enclosed with mpmath.iv (outward rounded interval\narithmetic); the lattice counts are exact integer enumerations.\n\nSections:\n A. M, Lambda, kappa_c, C_E = 8/kappa_c^2.\n B. Lattice geometry: tree links, owned plaquettes, dependence ranges,\n the overlap N_ov of the witness regions, C_* = C_E N_ov.\n C. The per-block constant c_1(lambda, eta) of the upper bound on the\n coarse action and the large-field rate a(lambda, kappa).\n D. The Kotecky-Preiss rate a_KP = 9 for the distance-one gas.\n E. Thresholds lambda*(kappa), beta* = 4 lambda*.\n F. The inherited count at scale j (witness boxes of lem:scalewitness):\n m_j, H\'_j, thresholds beta^pw_j, and k_* - j^pw_max at 2001 couplings.\n"""\nimport itertools\n\ndef iv_asin(x): # asin by atan2, valid on (-1,1)\n return iv.atan2(x, iv.sqrt(1 - x**2))\nfrom mpmath import iv, mp\n\niv.dps = 80\nmp.dps = 80\n\ndef ivlo(x): return mp.make_mpf(x._mpi_[0])\ndef ivhi(x): return mp.make_mpf(x._mpi_[1])\ndef show(name, x):\n print(f"{name} in [{mp.nstr(ivlo(x), 12)}, {mp.nstr(ivhi(x), 12)}]")\n\nprint("=== A. basic constants ===")\nalpha = 2 * iv_asin(1 / (2 * iv.sqrt(2)))\nLam = alpha / iv.sin(alpha)\none_m = 1 - iv.mpf(7) / 8 * Lam\nM = 1 + 2 / one_m**3\nlogM = iv.log(M)\nshow("alpha", alpha); show("Lambda", Lam); show("1-7Lambda/8", one_m)\nshow("M", M); show("log M", logM); show("8 log M", 8 * logM)\nassert M.b < 2.4e4\npsi_c = iv_asin(1 / (4 * iv.sqrt(2))) / 3\nkappa_c = 2 * iv.sqrt(2) * iv.sin(psi_c / 2)\nC_E = 8 / kappa_c**2\nshow("kappa_c", kappa_c); show("C_E = 8/kappa_c^2", C_E)\nassert (iv.mpf(\'16.003\')**2).b < C_E.a\nprint("16.003^2 =", mp.nstr((iv.mpf(\'16.003\')**2).b, 8), "< C_E: OK")\n\nprint("\\n=== B. lattice geometry (exact enumeration) ===")\nD = 4\nE = [tuple(1 if i == m else 0 for i in range(D)) for m in range(D)]\ndef add(x, y): return tuple(a + b for a, b in zip(x, y))\ndef blk(x): return tuple(a // 2 for a in x)\ndef off(x): return tuple(a % 2 for a in x)\ndef is_tree(x, mu):\n o = off(x)\n return o[mu] == 0 and all(o[n] == 0 for n in range(mu + 1, D))\ndef link_class(x, mu):\n """(\'tree\',y) | (\'inside\',y) | (\'private\',(y,mu)) by the base block y."""\n y = blk(x); o = off(x)\n if is_tree(x, mu): return (\'tree\', y)\n if o[mu] == 0: return (\'inside\', y)\n return (\'private\', (y, mu))\ndef plaq_links(x, mu, nu):\n return [(x, mu), (add(x, E[mu]), nu), (add(x, E[nu]), mu), (x, nu)]\nplanes = [(m, n) for m in range(D) for n in range(m + 1, D)]\nB0 = list(itertools.product(range(2), repeat=D))\n# per block link census\ncnt = {\'tree\': 0, \'inside\': 0, \'private\': 0}\nfor x in B0:\n for mu in range(D):\n cnt[link_class(x, mu)[0]] += 1\nprint("links based in a block:", cnt)\nassert cnt == {\'tree\': 15, \'inside\': 17, \'private\': 32}\n# owned plaquettes of block 0\nowned = [(x, m, n) for x in B0 for (m, n) in planes]\nprint("owned plaquettes per block:", len(owned))\nassert len(owned) == 96\nok_active = ok_range = 0\ninside_owned = 0\nfor (x, m, n) in owned:\n cls = [link_class(*l) for l in plaq_links(x, m, n)]\n if any(c[0] != \'tree\' and (c[1] if c[0] != \'private\' else c[1][0]) == (0,)*D for c in cls):\n ok_active += 1\n bases = {blk(l[0]) for l in plaq_links(x, m, n)}\n allowed = {(0,)*D, E[m], E[n]}\n if bases <= allowed: ok_range += 1\n o = off(x)\n if o[m] == 0 and o[n] == 0: inside_owned += 1\nprint("owned plaquettes containing an active link based in the block:", ok_active)\nprint("owned plaquettes whose links are based in {y, y+e_mu, y+e_nu}:", ok_range)\nprint("owned plaquettes inside the block:", inside_owned)\nassert ok_active == 96 and ok_range == 96 and inside_owned == 24\n# the plaquettes of a block\'s links: f_y depends on Xi_y, Xi_{y+e_mu}\n# witness region of a coarse plaquette P=(y;mu,nu): blocks z with\n# z-y in {-1..2} in mu,nu and {-1,0,1} elsewhere (lem:coarsewitness)\ndef region(y, m, n):\n rngs = [range(-1, 3) if c in (m, n) else range(-1, 2) for c in range(D)]\n return {add(y, d) for d in itertools.product(*rngs)}\nprint("blocks in a witness region:", len(region((0,)*D, 0, 1)))\ndef verts(x, m, n):\n return [x, add(x, E[m]), add(x, E[n]), add(add(x, E[m]), E[n])]\nNov = 0; arg = None\ncand = list(itertools.product(range(-4, 5), repeat=D))\nregs = {(y, m, n): region(y, m, n) for y in cand for (m, n) in planes}\nfor (x, m, n) in owned:\n vb = {blk(v) for v in verts(x, m, n)}\n c = sum(1 for key, R in regs.items() if vb & R)\n if c > Nov: Nov, arg = c, (x, m, n)\nprint("N_ov = max_p #{P : p in N(P)} =", Nov, "at", arg)\n# sanity: no witness region in the enumeration window is cut off\nC_star = C_E * Nov\nshow("C_* = C_E N_ov", C_star)\n# number of coarse plaquettes whose witness region meets the plaquettes\n# owned by one block (used for the local form of the kernel bound)\nown_meet = set()\nfor (x, m, n) in owned:\n vb = {blk(v) for v in verts(x, m, n)}\n for key, R in regs.items():\n if vb & R: own_meet.add(key)\nprint("coarse plaquettes whose witness region meets Pi(y):", len(own_meet))\n\nprint("\\n=== C. c_1(lambda, eta) and a(lambda, kappa) ===")\n# A_1(c) <= 4(1+eta) lam Q_1(c) + L^4 c_1(lam, eta),\n# c_1 = 12 log 1.957 + 45 log 14 + 67.5 (1 + log(11520 (1+1/eta) lam)),\n# from rho^2 = 135/(2A), A = (1+1/eta) 96*90^2 lam.\nassert 2 * 96 * 90**2 // 135 == 11520 and 2 * 96 * 90**2 % 135 == 0\nK0 = 12 * iv.log(iv.mpf(\'1.957\')) + 45 * iv.log(14)\nshow("12 log 1.957 + 45 log 14", K0)\ndef c1(lam, eta=1):\n lam = iv.mpf(lam); eta = iv.mpf(eta)\n return K0 + iv.mpf(\'67.5\') * (1 + iv.log(11520 * (1 + 1 / eta) * lam))\ndef rho_opt(lam, eta=1):\n lam = iv.mpf(lam); eta = iv.mpf(eta)\n return iv.sqrt(iv.mpf(135) / (2 * (1 + 1 / eta) * 96 * 8100 * lam))\nshow("rho at lambda=100, eta=1", rho_opt(100))\nassert (46 * rho_opt(100)).b < 0.043\nfor lam in [\'1e3\', \'1e6\', \'1e12\', \'1e20\']:\n show(f"c_1({lam},1)", c1(lam))\ndef a_rate(lam, kappa, eta=1):\n lam = iv.mpf(lam); kappa = iv.mpf(kappa)\n return lam * kappa**2 - 8 * logM - c1(lam, eta)\n\ncfc = 14 * iv.mpf(\'90.6\')**3 * iv.mpf(384)**3\nshow("14*90.6^3*384^3 (thm LF2(ii))", cfc)\nassert ivhi(cfc) < 5.9e14\n\nprint("\\n=== D. Kotecky-Preiss rate ===")\n# connected sets (l^inf adjacency, 80 neighbours) of n blocks through a\n# block: <= 80^{2(n-1)} = 6400^{n-1}; incompatible with X: a block within\n# distance one of X, <= 81|X| choices. Condition with a(X)=b|X|:\n# 81 u/(1-6400 u) <= b, u = e^{-(a-b)}.\nb = iv.mpf(1) / 10; aKP = iv.mpf(9)\nu = iv.exp(-(aKP - b))\nlhs = 81 * u / (1 - 6400 * u)\nshow("u", u); show("81u/(1-6400u)", lhs)\nassert lhs.b <= b.a\n# optimal b, for the record\nimport math\nbopt = (-81 + math.sqrt(81**2 + 4 * 6400 * 81)) / (2 * 6400)\nprint("optimal b =", bopt, " least a =", bopt + math.log(6400 + 81 / bopt))\n\nprint("\\n=== E. thresholds lambda*(kappa): a(lambda,kappa) = 9 ===")\ndef threshold(f, lo, hi, target, rel=1e-8):\n lo = mp.mpf(lo); hi = mp.mpf(hi)\n assert f(lo).b < target and f(hi).a > target\n while hi / lo - 1 > rel:\n mid = mp.sqrt(lo * hi)\n v = f(mid)\n if v.b < target: lo = mid\n elif v.a > target: hi = mid\n else: break\n assert f(lo).b < target and f(hi).a > target\n return lo, hi\nfor kap in [\'0.08\', \'1e-2\', \'1e-4\', \'1e-8\']:\n k = mp.mpf(kap)\n lo0 = max(mp.mpf(100), mp.mpf(\'67.5\') / k**2) # a increasing beyond\n assert a_rate(lo0, kap).b < 9\n lo, hi = threshold(lambda l: a_rate(l, kap), lo0, 1e60, 9)\n print(f"kappa={kap}: lambda* in [{mp.nstr(lo,8)}, {mp.nstr(hi,8)}],"\n f" beta*=4lambda* in [{mp.nstr(4*lo,7)}, {mp.nstr(4*hi,7)}],"\n f" lambda* kappa^2 = {mp.nstr(hi*k**2,6)}")\n\nprint("\\n=== F. inherited count at scale j ===")\ndef coord_counts_brute(j):\n lo_off = -8 * 2**j + 2; hi_off = 9 * 2**j - 3\n m = sum(1 for yc in range(-10 * 2**j, 10 * 2**j)\n if any(lo_off <= t <= hi_off for t in (2 * yc, 2 * yc + 1)))\n H = 0\n for yc in range(0, 2**j + 1):\n h = sum(1 for Yc in range(-20, 21)\n if any(2**(j + 1) * Yc + lo_off <= t <= 2**(j + 1) * Yc + hi_off\n for t in (2 * yc, 2 * yc + 1)))\n H = max(H, h)\n return m, H\ndef coord_counts(j):\n # box of Y_c: [2^{j+1}Y_c - 8 2^j + 2, 2^{j+1}Y_c + 9 2^j - 3], even to odd\n m = 17 * 2**(j - 1) - 2\n # Y_c whose box meets {2y_c, 2y_c+1}: 2^{j+1}Y_c in [2y_c-9 2^j+3, 2y_c+8 2^j-1]\n P = 2**(j + 1); H = 0\n for yc in range(0, min(2**j, 4096)): # the count depends on y_c only through 2y_c mod 2^{j+1}; for j>12 the window 0..4095 covers the residues near the ends, checked below\n a = 2 * yc - 9 * 2**j + 3; b = 2 * yc + 8 * 2**j - 1\n H = max(H, b // P - (-(-a // P)) + 1)\n # an interval of 17 2^j - 4 + 1 points meets at most floor(...)+1 multiples\n assert H <= (17 * 2**j - 4) // P + 1\n if j >= 3: assert H == (17 * 2**j - 4) // P + 1\n return m, H\nfor j in range(1, 11):\n assert coord_counts(j) == coord_counts_brute(j), j\nprint("closed-form counts agree with enumeration for j<=10")\nrho = iv.mpf(\'1e-4\')\nC0 = iv.mpf(1) / 2 + iv.mpf(2) / 3 * iv.log(24 * iv.pi**3)\nC1 = C0 + iv.log(12800) / 6\ndef a0(beta, j):\n lam = iv.mpf(beta) / 4\n rho0 = rho / (iv.mpf(\'1.01\') * iv.mpf(\'1.023\') * 4**j)\n return lam * rho0**2 - 8 * logM - c1(lam)\ndef need(m, H):\n # A_j >= 9 <=> a_0 >= 9H + log(mH-1) + mH log(mH/(mH-1))\n mH = iv.mpf(m * H)\n return 9 * H + iv.log(mH - 1) + mH * iv.log(mH / (mH - 1))\nbeta_pw = {}\nrows = []\nfor j in range(1, 31):\n mc, Hc = coord_counts(j)\n m, H = mc**4, Hc**4\n req = need(m, H)\n f = lambda bb, j=j: a0(bb, j)\n lo, hi = threshold(f, 1e6, 1e60, req.b)\n # certify: a0(hi) > req.b >= every point of req, a0(lo) < req.a ?\n assert a0(hi, j).a > req.b\n lo2, hi2 = threshold(f, 1e6, 1e60, req.a)\n assert a0(lo2, j).b < req.a\n beta_pw[j] = (lo2, hi)\n rows.append((j, mc, Hc, m, H, req, lo2, hi))\n if j <= 6 or j % 5 == 0:\n print(f"j={j}: m_j={mc}^4, H\'_j={Hc}^4, a_0 needed in"\n f" [{mp.nstr(ivlo(req),9)},{mp.nstr(ivhi(req),9)}], beta^pw_j in"\n f" [{mp.nstr(lo2,7)}, {mp.nstr(hi,7)}],"\n f" 16^-j beta^pw_j <= {mp.nstr(hi/16**j,5)}")\nprint("max_j 16^-j beta^pw_j (1<=j<=30):",\n mp.nstr(max(r[7] / 16**r[0] for r in rows), 6))\nprint("min_j 16^-j beta^pw_j (1<=j<=30):",\n mp.nstr(min(r[6] / 16**r[0] for r in rows), 6))\n# monotone thresholds\nfor j in range(1, 30):\n assert beta_pw[j][1] < beta_pw[j + 1][0]\nprint("beta^pw_j increasing in j: OK")\n# islandswide values (s=5) for comparison\niw = {1: mp.mpf(\'2.89281e15\'), 2: mp.mpf(\'4.62936e16\'), 3: mp.mpf(\'1.18541e18\')}\nfor j in (1, 2, 3):\n print(f"j={j}: beta*_j(islandswide)/beta^pw_j = "\n f"{mp.nstr(iw[j]/beta_pw[j][1],5)} to {mp.nstr(iw[j]/beta_pw[j][0],5)}")\n\ndef kstar(beta):\n B = iv.mpf(beta)\n r = iv.sqrt(96 * (iv.log(B) + C1) / B)\n t = iv.log(iv.mpf(\'1e-4\') / (iv.mpf(\'1.01\') * r)) / iv.log(4)\n fa, fb = int(mp.floor(t.a)), int(mp.floor(t.b))\n assert fa == fb, "k_* not certified"\n return fa\nfrom collections import Counter\ndiffs = Counter(); jlist = Counter()\nfor i in range(2001):\n beta = mp.mpf(10)**(22 + mp.mpf(20) * i / 2000)\n ks = kstar(beta)\n jm = 0\n for j in range(1, 31):\n lo, hi = beta_pw[j]\n if beta >= hi: jm = j\n elif beta < lo: break\n else: raise AssertionError("beta inside a threshold enclosure")\n assert jm < 30\n diffs[ks - jm] += 1\nprint("k_* - j^pw_max over 2001 couplings in [1e22,1e42]:", dict(diffs))\n', 'd5/layer_constants.py': '#!/usr/bin/env python3\n"""Explicit constants for the Hessian of the layer law in the link-logarithm\ncoordinates zeta (thm:layerbound of main.tex), from the constants of\nprop:explicitdecay of main.tex. mpmath at 40 digits; every printed value is\nan upper bound rounded up in the last printed digit (the inputs are the\nupper bounds of the paper, all formulas are monotone in them).\n\nPart 1 reproduces the chain b, g0, h0, g1, y, sbar, pbar, g2, k1 of\nprop:explicitdecay at theta = 0.197 (check against the paper: 0.862, 17.37,\n14.96, 5.80, 7.41, 1966).\nPart 2 computes the new constants at theta = 0 (lower bound) and 0.197\n(weighted norm), and the least C_lambda for which m\' >= lambda/60.\nPart 3: the island-threshold arithmetic under the corrected calmness\nhypothesis (cor:twoislands of main.tex)."""\nfrom mpmath import mp, mpf, sqrt, exp, cosh, sinh, log, pi, e, findroot, ceil\nmp.dps = 40\n\nKAPPA = mpf(\'1e-8\') # kappa_0 <= 1e-8 (hypothesis of lem:smallframes)\nC3S = mpf(\'1.29e-8\') # c_3 s <= 1.29e-8 (from 4e5 c_3 (kappa+s) <= 1/195)\nC3KP = mpf(\'7.7e-8\') # c_3 kappa\' <= 7.7e-8, kappa\' = kappa_0 + 6 s\nDIMG = 3 # SU(2)\nH1 = mpf(\'17.001\') # ||(AB*)^{-1}|| in the norm sum_k ||z_k||\nKPAPER = mpf(2068) # ||Hess_xi Hbar||_(0.197) <= 2068 lambda (proof of prop:explicitdecay)\nC6_OVER_C3SQ = mpf(\'6.81e5\') * DIMG # c_6 = 6.81e5 dim G c_3^2\n\ndef up(x, digits=4):\n """round a positive mpf up to `digits` significant digits"""\n from mpmath import floor, log10\n ex = int(floor(log10(x)))\n sc = mpf(10)**(digits-1-ex)\n return ceil(x*sc)/sc\n\ndef chain(th, thpp=mpf(\'0.6\'), need_g2=True):\n """the constants of prop:explicitdecay at weight theta = th"""\n eth = exp(th)\n b = eth*sqrt(mpf(\'0.5\')+mpf(\'1e-4\'))\n epsA = mpf(\'7.35\')*C3S\n AB = sqrt(48)*eth*epsA\n sig = (sqrt(11)/8 + 260*KAPPA)/(mpf(1)/8 - 260*KAPPA)\n sbar = sqrt(1 + 2*sig**2*eth**2)\n g0 = 1/(mpf(1)/16 - 700*KAPPA - (cosh(2*th)-1)*(mpf(1)/16 + 454*KAPPA))\n E = AB*b\n h0 = g0/(1 - g0*E)\n g1 = g0/(1 - g0*(2*E + AB**2))\n y = b*h0\n pbar = sbar*(1 + y*AB)\n if th > 0 and need_g2:\n d = chain(thpp, need_g2=False) # ||M||_(theta\'\') with M = Y(A-B)S\n Mpp = d[\'y\']*d[\'AB\']*d[\'sbar\']\n g2 = 1/(1 - 2*sig**2*sinh(th)**2 - 2*(th/thpp)**2*Mpp**2)\n else:\n g2 = mpf(1)\n x1 = 2*(2+mpf(\'1e-4\'))*H1*eth**2*pbar**2\n k1 = 48*eth*pbar**2 + 12*C3KP*x1\n return dict(th=th, eth=eth, b=b, epsA=epsA, AB=AB, sig=sig, sbar=sbar, g0=g0,\n h0=h0, g1=g1, y=y, pbar=pbar, g2=g2, x1=x1, k1=k1)\n\nprint("=== Part 1: the chain of prop:explicitdecay at theta = 0.197 (paper: 0.862, 17.37, 14.96, 5.80, 7.41, 1966)")\nd = chain(mpf(\'0.197\'))\nfor k in (\'b\',\'g0\',\'h0\',\'g1\',\'y\',\'sbar\',\'pbar\',\'g2\',\'k1\',\'x1\'):\n print(f" {k:5s} <= {up(d[k],5)}")\n\nprint("\\n=== Part 2: constants of the zeta-coordinate Hessian (thm:layerbound, Step 4)")\n# l^1 norms (theta-independent)\nS11 = 1 + 2*mpf(\'8.01\')*(mpf(1)/8 + 260*KAPPA) # ||S||_{1->1}\nY11 = (2+mpf(\'1e-4\'))*H1 # ||Y||_{1->1}\nepsA = mpf(\'7.35\')*C3S\nAB11 = 2*epsA # ||A-B||_{1->1}\nq1 = S11*(1 + Y11*AB11) # ||Pbar||_{1->1}\ndg11 = Y11*AB11*S11 # ||Dg||_{1->1}\nj1 = 1/(1-dg11) # ||J||_{1->1}\nprint(f" ||S||_1->1 <= {up(S11,6)}, ||Pbar||_1->1 = q1 <= {up(q1,6)}, ||Dg||_1->1 <= {up(dg11,3)}, j1 <= {up(j1,8)}")\n\ndef zeta_terms(th):\n d = chain(th)\n eth, y, pbar, x1 = d[\'eth\'], d[\'y\'], d[\'pbar\'], d[\'x1\']\n dg = y*d[\'AB\']*d[\'sbar\'] # ||Dg||_(theta)\n j = 1/(1-dg) # ||J||_(theta)\n n1 = 12*q1 # ||grad_xi Hbar||_inf <= lambda*(c3 kappa\')*n1/c3 + n0 c3\n n0 = (mpf(\'0.84\') + 30 + 6*y)*q1 # lambda-independent part of ||grad Hbar||_inf, times c_3\n # middle term , per |u||u\'|:\n mid_lam = 12*C3KP*q1*j1*x1*j**2 # times lambda\n mid_c3 = n0*j1*x1*j**2 # times c_3^2\n # third term (Hessian of log det(1+Dg) o xi), per |u||u\'|, times c_3^2:\n W3a = 2*DIMG*eth**3*pbar**4*y**2*j**4\n W3b = 4*DIMG*eth**3*pbar**3*y**2*j*j**2\n W3c = 2*DIMG*eth**2*pbar**3*y*j*j**2 # (times c_3 only; bounded by c_3^2)\n W3d = 2*DIMG*pbar*y*j*x1*j**2\n W3e = 2*DIMG*j*y*pbar*q1*j1*x1*j**2\n third_c3 = W3a+W3b+W3c+W3d+W3e\n return dict(d=d, dg=dg, j=j, n1=n1, n0=n0, mid_lam=mid_lam, mid_c3=mid_c3,\n W3=(W3a,W3b,W3c,W3d,W3e), third_c3=third_c3)\n\nz0 = zeta_terms(mpf(0))\nprint(" theta = 0:")\nprint(f" ||Dg|| <= {up(z0[\'dg\'],3)}, j0 = ||J|| <= {up(z0[\'j\'],8)}, y0 <= {up(z0[\'d\'][\'y\'],5)}, pbar0 <= {up(z0[\'d\'][\'pbar\'],5)}, x1(0) <= {up(z0[\'d\'][\'x1\'],5)}")\nprint(f" n0 <= {up(z0[\'n0\'],4)} (x c_3), 12 q1 (c3 kappa\') <= {up(12*q1*C3KP,4)} (x lambda / c_3)")\nprint(f" middle term: {up(z0[\'mid_lam\'],4)} lambda + {up(z0[\'mid_c3\'],4)} c_3^2")\nprint(f" third term : W3a..W3e = " + ", ".join(f"{up(w,4)}" for w in z0[\'W3\']) + f" sum = {up(z0[\'third_c3\'],4)} c_3^2")\nlam_indep0 = z0[\'mid_c3\'] + z0[\'third_c3\']\nprint(f" lambda-independent total (besides c_6): {up(lam_indep0,4)} c_3^2 = {up(lam_indep0/C6_OVER_C3SQ,4)} c_6")\n\ndef mprime_over_lambda(Cl):\n """lower bound of Hess_zeta U / lambda under lambda >= Cl c_6"""\n z = z0\n lb = (mpf(1)/30 - 1/mpf(Cl))/(1+z[\'dg\'])**2\n return lb - z[\'mid_lam\'] - lam_indep0/(mpf(Cl)*C6_OVER_C3SQ)\n\nfor Cl in (60, 120, 180, 200, 220, 240, 300, 400):\n v = mprime_over_lambda(Cl)\n print(f" C_lambda = {Cl:4d}: m\'/lambda >= {float(v):+.5f} (1/60 = {1/60:.5f}) {\'OK\' if v >= mpf(1)/60 else \'--\'}")\n# least integer C_lambda with m\' >= lambda/60\nCl = 60\nwhile mprime_over_lambda(Cl) < mpf(1)/60: Cl += 1\nprint(f" least integer C_lambda with m\' >= lambda/60: {Cl}")\n\nCL = 240\nzw = zeta_terms(mpf(\'0.197\'))\nprint(" theta = 0.197:")\nprint(f" ||Dg||_(th) <= {up(zw[\'dg\'],3)}, j_th <= {up(zw[\'j\'],8)}")\nprint(f" middle term: {up(zw[\'mid_lam\'],4)} lambda + {up(zw[\'mid_c3\'],4)} c_3^2")\nprint(f" third term : W3a..W3e = " + ", ".join(f"{up(w,4)}" for w in zw[\'W3\']) + f" sum = {up(zw[\'third_c3\'],4)} c_3^2")\nlam_indep_w = zw[\'mid_c3\'] + zw[\'third_c3\']\nKp = zw[\'j\']**2*KPAPER + zw[\'mid_lam\'] + lam_indep_w/(CL*C6_OVER_C3SQ)\nprint(f" with lambda >= {CL} c_6: K\'/lambda <= {up(Kp,5)}")\nalpha_max = mpf(\'0.197\')/sqrt(240*Kp)\nprint(f" admissible alpha <= theta\'(lambda/(240 K\'))^(1/2) = {up(alpha_max,4)} (need >= 2.5e-4: {\'OK\' if alpha_max >= mpf(\'2.5e-4\') else \'FAIL\'})")\nprint(f" with lambda >= 60 c_6 instead: K\'/lambda <= {up(zw[\'j\']**2*KPAPER + zw[\'mid_lam\'] + lam_indep_w/(60*C6_OVER_C3SQ),5)}")\n\nprint("\\n=== Part 2b: chart inclusion (thm:layerbound, Step 2) and the size of h")\nc3r = C3S/32\nt = mpf(\'31.5\') # ||X||_inf <= 31.5 r for zeta in D_{1.25 r}\nzk = 17*12*c3r*t**2 # max_k ||z_k|| / r : 204 (c_3 r) t^2 r\nprint(f" c_3 r <= {up(c3r,3)}; max_k||z_k|| <= {up(zk,3)} r; ||eta||_inf <= {up(t*(1+ mpf(\'0.88\')*17*12*c3r*t),6)} r < 32 r; ||h||_inf <= {up(mpf(\'0.88\')*zk,3)} r")\n\nprint("\\n=== Part 3: island threshold arithmetic (cor:twoislands)")\nC0 = mpf(1)/2 + mpf(2)/3*log(24*pi**3)\nM, H = mpf(11)**4, mpf(6)**4\ndef beta_star(rho, s, join):\n Dn = (2*join+1)**4 - 1\n logq = -H*(log(2)+2*log(Dn)) - log(e*M*H)\n f = lambda b: 6*(log(b)+C0) - b*rho**2/16 - logq\n return findroot(f, 16*abs(logq)/rho**2*mpf(\'1.02\')), logq\nfor rho, s in ((mpf(\'1e-8\'),1),(mpf(\'1e-8\'),5),(mpf(\'1e-9\'),1)):\n b, lq = beta_star(rho, s, 2*s+1)\n print(f" check paper: rho={float(rho):.0e} s={s}: |log q*|={float(-lq):.1f} beta*={float(b):.4e}")\n# calmness: kappa_0 <= eta + 30 r (a plaquette has at most two path links),\n# s = 32 r, r = 43 rho, eta = 92 rho:\ncoef = 92 + 30*43 + 32*43\nprint(f" kappa_0 + s <= {coef} rho; SU(2) chart hypothesis kappa_0 + s <= 6.0e-13 => rho <= {float(mpf(\'6.0e-13\')/coef):.5e}")\nrho_c = mpf(\'2.17e-16\') # below 6.0e-13/coef = 2.1755e-16\nassert coef*rho_c <= mpf(\'6.0e-13\')\nfor s in (1,5):\n for join in (2*s+8, 2*s+10):\n b, lq = beta_star(rho_c, s, join)\n print(f" rho={float(rho_c):.3e} s={s} join={join}: |log q*|={float(-lq):.1f} beta*={float(b):.4e}")\nprint(f" beta_W >= 4 C_lambda c_6 = {float(4*CL*mpf(\'9.3e14\')):.3e} (C_lambda = {CL}, c_6 <= 9.3e14 for SU(2))")\n', 'd5/loop_filling.py': '"""Checks for the loop remainders of the one-step bound.\n\n(A) s(g_1...g_A) <= A sum s(g_j) on random unitary matrices.\n(B) The ordered filling by adjacent transpositions: on random closed lattice\n paths in Z^4 with random SU(3) links, V_C equals the ordered product of the\n transported plaquettes, the number of plaquettes is the number of\n inversions <= l(l-1)/2, and every plaquette lies in the bounding box.\n(C) At a flat background, the second derivative of s(V_C(t)) along V_0 e^{tw}\n is at most (A_C/N) sum_p m_Cp ||D_p w||^2 (finite differences).\n(D) R_m = eps (1 - cos t) cos(m t): |R_m| <= eps s and R_m\'\' = -eps m^2 at pi/2.\n(E) The constants of the corollary for SU(2), lambda = 1e100.\n"""\nimport itertools, math, random\nimport numpy as np\nfrom mpmath import mp, mpf, sqrt, sin, pi\n\nrng = np.random.default_rng(1)\nrandom.seed(1)\nfails = 0\ndef check(ok, msg):\n global fails\n print(("PASS " if ok else "FAIL ") + msg)\n if not ok:\n fails += 1\n\ndef haar_unitary(n, special=False):\n z = (rng.normal(size=(n, n)) + 1j * rng.normal(size=(n, n))) / math.sqrt(2)\n q, r = np.linalg.qr(z)\n q = q @ np.diag(np.diag(r) / abs(np.diag(r)))\n if special:\n q = q / np.linalg.det(q) ** (1.0 / n)\n return q\n\ndef s(g):\n return 1 - np.trace(g).real / g.shape[0]\n\n# (A)\nworst = 0.0\nfor _ in range(2000):\n A = random.randint(1, 8); N = random.randint(1, 4)\n r = 10.0 ** random.uniform(-4, 0.5)\n gs = []\n for _ in range(A):\n z = rng.normal(size=(N, N)) + 1j * rng.normal(size=(N, N))\n X = r * (z - z.conj().T) / 2\n w, U = np.linalg.eigh(-1j * X)\n gs.append(U @ np.diag(np.exp(1j * w)) @ U.conj().T)\n lhs = s(np.linalg.multi_dot(gs + [np.eye(N)]))\n rhs = A * sum(s(g) for g in gs)\n worst = max(worst, (lhs - rhs) / max(rhs, 1e-300))\ncheck(worst <= 1e-9, f"(A) product inequality on 2000 random products near and far from I, max (lhs-rhs)/rhs = {worst:.2e}")\n\n# (B) lattice paths\nD = 4\ndef steps_of_random_closed_path(l):\n while True:\n st = [(random.randrange(D), random.choice((1, -1))) for _ in range(l - 1)]\n pos = [0] * D\n for mu, e in st:\n pos[mu] += e\n nz = [mu for mu in range(D) if pos[mu] != 0]\n if sum(abs(p) for p in pos) == 1:\n mu = nz[0]\n st.append((mu, -pos[mu]))\n return st\n\nclass Field:\n def __init__(self, N=3):\n self.N = N; self.links = {}\n def link(self, x, mu):\n key = (tuple(x), mu)\n if key not in self.links:\n self.links[key] = haar_unitary(self.N, special=True)\n return self.links[key]\n def step(self, x, mu, e):\n if e == 1:\n return self.link(x, mu)\n y = list(x); y[mu] -= 1\n return self.link(y, mu).conj().T\n def hol(self, x, st):\n x = list(x); g = np.eye(self.N, dtype=complex)\n for mu, e in st:\n g = g @ self.step(x, mu, e); x[mu] += e\n return g, x\n\ndef fill(x0, st):\n """Bubble sort by direction; return list of (h-path prefix, x, plaquette word)."""\n st = list(st); factors = []\n changed = True\n while changed:\n changed = False\n for i in range(len(st) - 1):\n if st[i][0] > st[i + 1][0]:\n factors.append((list(st[:i]), st[i], st[i + 1]))\n st[i], st[i + 1] = st[i + 1], st[i]\n changed = True\n return factors, st\n\ndef inversions(st):\n return sum(1 for i in range(len(st)) for j in range(i + 1, len(st)) if st[i][0] > st[j][0])\n\nmaxerr = 0.0; okcount = True; okbox = True; npaths = 0\nfor l in range(4, 15, 2):\n for _ in range(40):\n st = steps_of_random_closed_path(l)\n F = Field(3)\n x0 = [0] * D\n VC, end = F.hol(x0, st)\n assert end == x0\n factors, sorted_st = fill(x0, st)\n okcount &= len(factors) == inversions(st) <= l * (l - 1) // 2\n # bounding box of the path\n pts = [list(x0)]; x = list(x0)\n for mu, e in st:\n x[mu] += e; pts.append(list(x))\n lo = [min(p[m] for p in pts) for m in range(D)]; hi = [max(p[m] for p in pts) for m in range(D)]\n prod = np.eye(3, dtype=complex)\n for pre, u, v in factors:\n h, xs = F.hol(x0, pre)\n # loop u v u\'^{-1} v\'^{-1} from xs\n P, _ = F.hol(xs, [u, v, (u[0], -u[1]), (v[0], -v[1])])\n # plaquette corners\n corners = [xs, [xs[m] + (u[1] if m == u[0] else 0) for m in range(D)],\n [xs[m] + (v[1] if m == v[0] else 0) for m in range(D)],\n [xs[m] + (u[1] if m == u[0] else 0) + (v[1] if m == v[0] else 0) for m in range(D)]]\n okbox &= all(lo[m] <= c[m] <= hi[m] for c in corners for m in range(D))\n prod = prod @ (h @ P @ h.conj().T)\n Vsorted, _ = F.hol(x0, sorted_st)\n maxerr = max(maxerr, np.abs(Vsorted - np.eye(3)).max(), np.abs(prod - VC).max())\n npaths += 1\ncheck(maxerr < 1e-10, f"(B) ordered filling identity on {npaths} random closed paths, lengths 4-14, max error {maxerr:.1e}")\ncheck(okcount, "(B) number of plaquettes = number of inversions <= l(l-1)/2")\ncheck(okbox, "(B) every plaquette of the filling lies in the bounding box of the path")\n\n# (C) flat Hessian\ndef su_alg(N):\n z = rng.normal(size=(N, N)) + 1j * rng.normal(size=(N, N))\n X = (z - z.conj().T) / 2\n return X - np.trace(X) / N * np.eye(N)\n\ndef expm(X):\n w, U = np.linalg.eigh(-1j * X)\n return U @ np.diag(np.exp(1j * w)) @ U.conj().T\n\nworst = -1e9\nfor trial in range(30):\n N = 2 + trial % 2\n l = random.choice((4, 6, 8, 10))\n st = steps_of_random_closed_path(l)\n # flat background: pure gauge V_{x,mu} = g_x g_{x+mu}^{-1}\n gs = {}\n def gsite(x):\n k = tuple(x)\n if k not in gs: gs[k] = haar_unitary(N, special=True)\n return gs[k]\n x0 = [0] * D\n factors, _ = fill(x0, st)\n # collect links of the path and of the plaquettes\n def path_links(x, word):\n x = list(x); out = []\n for mu, e in word:\n y = list(x)\n if e == -1: y[mu] -= 1\n out.append((tuple(y), mu)); x[mu] += e\n return out\n W = {}\n allk = set(path_links(x0, st))\n plist = []\n for pre, u, v in factors:\n x = list(x0)\n for mu, e in pre: x[mu] += e\n word = [u, v, (u[0], -u[1]), (v[0], -v[1])]\n plist.append((x, word)); allk |= set(path_links(x, word))\n for k in allk:\n W[k] = su_alg(N)\n def field_at(t):\n F = Field(N)\n for (y, mu) in allk:\n yp = list(y); yp[mu] += 1\n F.links[(y, mu)] = gsite(y) @ gsite(yp).conj().T @ expm(t * W[(y, mu)])\n return F\n h = 1e-4\n def sC(t):\n F = field_at(t); g = F.hol(x0, st)[0]\n return np.sum(np.abs(np.eye(N) - g) ** 2) / (2 * N) # = s(g) for unitary g, without cancellation\n second = (sC(h) - 2 * sC(0) + sC(-h)) / h ** 2\n # D_p w via derivative of plaquette holonomy\n bound = 0.0\n for x, word in plist:\n Fp, Fm = field_at(h), field_at(-h)\n dP = (Fp.hol(x, word)[0] - Fm.hol(x, word)[0]) / (2 * h)\n bound += np.sum(np.abs(dP) ** 2)\n bound *= len(plist) / N\n worst = max(worst, (second - bound) / (bound + 1e-3))\n assert abs(sC(0)) < 1e-12\ncheck(worst <= 1e-6, f"(C) flat pure-gauge backgrounds: d2 s(V_C) <= (A_C/N) sum ||D_p w||^2, max excess / (bound + 1e-3) {worst:.1e}")\n\n# (D)\nmp.dps = 40\nok = True\neps = mpf(1)\nfor m in (4, 8, 12, 40):\n f = lambda t: eps * (1 - mp.cos(t)) * mp.cos(m * t)\n d2 = mp.diff(f, mp.pi / 2, 2)\n ok &= abs(d2 + eps * m * m) < mpf(10) ** -20\n ok &= all(abs(f(t)) <= eps * (1 - mp.cos(t)) + mpf(10) ** -30 for t in [mpf(k) / 37 for k in range(0, 233)])\ncheck(ok, "(D) R_m\'\' = -eps m^2 at pi/2 for m = 4, 8, 12, 40, and |R_m| <= eps s")\n\n# (E)\ncstar = 1 / (1 + sqrt(mpf(21) / 8)) ** 2\nlam = mpf(10) ** 100; dG = mpf(1) / 3; e = mpf(\'1.63e-9\')\ndef epsdd(n):\n Cn = 1 + 1 / (4 * sin(pi / (2 * n)) ** 2)\n return (e + dG * Cn / lam) / (2 * cstar)\nprint("2 c_* =", mp.nstr(2 * cstar, 8))\nfor n in (2, 1024, 10 ** 6, 10 ** 40):\n print(f" n = {n}: eps\'\' = {mp.nstr(epsdd(n), 6)}")\ncheck(epsdd(10 ** 40) <= mpf(\'5.60e-9\'), "(E) eps\'\' <= 5.60e-9 for n <= 1e40")\nlo_, hi_ = mpf(10) ** 40, mpf(10) ** 60\nfor _ in range(200):\n mid = sqrt(lo_ * hi_)\n if epsdd(mid) <= mpf(\'0.1\'): lo_ = mid\n else: hi_ = mid\nprint(" largest n with eps\'\' <= 0.1:", mp.nstr(lo_, 6))\ncheck(epsdd(mpf(\'9.2e49\')) <= mpf(\'0.1\'), "(E) eps\'\' <= 0.1 for n <= 9.2e49")\nprint(f"{fails} failures")\n', 'd5/relstep_constants.py': '"""Certified constants for relstep.tex and NOTE.md (interval arithmetic,\nmpmath.iv). Every printed bound is an end point of an interval that\ncontains the exact value of the stated formula.\n\n c_* = (1 + sqrt(21/8))^(-2) S_W >= c_* Q_1\n C_n = 1 + 1/(4 sin^2(pi/(2n))) dist(w,G)^2 <= C_n Q_1(w)\n C_n^- = 1/(12 sin^2(pi/(2n+2))) no constant below C_n^- works\n eps\' = (eps_1 + delta_G/lambda) C_n / (2 c_*) relative one-step error\n delta_G = 1/3 for SU(2) (|Hess sum log j(0)| = |Tr ad_w^2|/12)\n\neps_1 is the constant of hypothesis (H); the text uses the example value\neps_1 = 1.63e-9 at lambda = 1e100.\n"""\nfrom mpmath import iv, mpf\niv.dps = 40\nI = iv.mpf\npi = iv.pi\n\ndef up(x): return x.b\ndef lo(x): return x.a\n\nprint("== constants of the window lemma")\ncstar = 1 / (1 + iv.sqrt(I(21) / 8)) ** 2\nprint(f" c_* in [{float(lo(cstar)):.6f}, {float(up(cstar)):.6f}] (claim c_* > 0.1456)")\nassert lo(cstar) > mpf(\'0.1456\')\n# ingredients of c_*: entering averages and plaquettes\nprint(" 7/256 * 8 =", 7 * 8 / 256, " (sum |v\'|^2 <= (7/32) Q); 12*7/32 =", 12 * 7 / 32)\n\ndef Cn(n): return 1 + 1 / (4 * iv.sin(pi / (2 * n)) ** 2)\ndef Cmin(n): return 1 / (12 * iv.sin(pi / (2 * n + 2)) ** 2)\n\nprint("== C_n (upper, proved) and C_n^- (lower, test field); asymptotics n^2/pi^2 and n^2/(3 pi^2)")\nprint(" n C_n<= 1+n^2/4 C_n^->= (n+1)^2/(3pi^2)<= ratio C_n/C_n^-")\nfor n in [1, 2, 3, 4, 5, 6, 8, 16, 32, 64, 128, 1024, 10**4]:\n c, cm = Cn(n), Cmin(n)\n simple = 1 + I(n) ** 2 / 4\n asym = I(n + 1) ** 2 / (3 * pi ** 2)\n assert up(c) <= lo(simple) + mpf(\'1e-30\')\n assert lo(cm) >= up(asym) - mpf(\'1e-30\')\n print(f" {n:6d} {float(up(c)):12.6g} {float(up(simple)):12.6g} {float(lo(cm)):12.6g} {float(up(asym)):14.6g} {float(up(c/cm)):12.4f}")\n\n# epsilon of hypothesis (H): the example value used in the text\neps1 = I(\'1.63e-9\')\nlam = I(\'1e100\'); deltaG = I(1) / 3\nepsabs = eps1 + deltaG / lam\n\nprint("== relative constant eps\' = (eps_1 + delta_G/lambda) C_n / (2 c_*)")\nfor n in [2, 4, 8, 16, 64, 256, 1024, 4096]:\n e = epsabs * Cn(n) / (2 * cstar)\n print(f" n={n:5d}: eps\' <= {float(up(e)):.4g}")\n# largest n (power of two not needed) with eps\' <= 0.1, via C_n <= 1 + n^2/4\ndef ok(n): return up(epsabs * (1 + I(n) ** 2 / 4) / (2 * cstar)) <= mpf(\'0.1\')\nlo_n, hi_n = 1, 2\nwhile ok(hi_n): hi_n *= 2\nwhile hi_n - lo_n > 1:\n mid = (lo_n + hi_n) // 2\n lo_n, hi_n = (mid, hi_n) if ok(mid) else (lo_n, mid)\nnmax = lo_n # ok(nmax) and not ok(nmax+1); C_n increases with n\nassert ok(nmax) and not ok(nmax + 1)\nprint(f" eps\' <= 0.1 for every n <= {nmax} (checked through C_n <= 1 + n^2/4)")\n\nprint("== across scales: windows of side n_k = n_1 2^(1-k), k = 1..K, n_K >= 1")\nprint(" sum_k C_{n_k} <= K + n_1^2/3 (from C_n <= 1 + n^2/4 and sum 4^(1-k)/4 <= 1/3)")\nfor m in [1, 4, 8, 12]:\n n1 = 2 ** m; K = m + 1\n s = sum((Cn(2 ** (m - k)) for k in range(K)), I(0))\n bound = K + I(n1) ** 2 / 3\n assert up(s) <= lo(bound)\n tot = epsabs * s / (2 * cstar)\n print(f" n_1=2^{m:2d}, K={K:2d}: sum C <= {float(up(s)):.6g} <= K + n_1^2/3 = {float(lo(bound)):.6g};"\n f" sum eps\'_k <= {float(up(tot)):.4g} (constant eps_1)")\nK = 13\none = I(4) ** (K - 1) * eps1\nallk = sum((I(4) ** (K - k) for k in range(1, K + 1)), I(0)) * eps1\nprint(f" the same errors kept absolute (n_1=2^12, K={K}): the error of scale 1 at the last scale,"\n f" 4^(K-1) eps_1 <= {float(up(one)):.4g}; all K errors, sum_k 4^(K-k) eps_1 <= {float(up(allk)):.4g}")\n', 'd5/rough_certificate.py': '"""Exact four-link counterexample; Python standard library, integer arithmetic.\n\nThis verifies the finite identities used in ROUGH_BACKGROUND.md. The note\nproves that the curve stays on the nonlinear fibre near t=0.\n"""\nfrom collections import Counter\nfrom itertools import product, combinations\nimport json\n\nFINE_SIDE = 4\nCOARSE_SIDE = 2\nXI = {((0, 1, 1, 1), 1): -1,\n ((0, 1, 1, 1), 2): 1,\n ((0, 1, 0, 0), 1): 1,\n ((0, 0, 1, 0), 2): -1}\n\ndef shift(x, mu):\n out = list(x)\n out[mu] = (out[mu] + 1) % FINE_SIDE\n return tuple(out)\n\ndef centre(x, mu):\n return 1 if x[mu] % 2 == 0 else (-1) ** sum(x[nu] // 2 for nu in range(mu))\n\ndef tree(x, mu):\n return x[mu] % 2 == 0 and all(x[nu] % 2 == 0 for nu in range(mu + 1, 4))\n\nassert all(not tree(*e) for e in XI)\nconstraints = []\nfor y in product(range(COARSE_SIDE), repeat=4):\n for mu in range(4):\n total = 0\n for off in product(range(2), repeat=4):\n x = tuple(2 * y[j] + off[j] for j in range(4))\n total += XI.get((x, mu), 0) + XI.get((shift(x, mu), mu), 0)\n constraints.append(total)\nassert len(constraints) == 64 and all(a == 0 for a in constraints)\ncounts = Counter()\nfor x in product(range(FINE_SIDE), repeat=4):\n for mu, nu in combinations(range(4), 2):\n edges = [(x, mu), (shift(x, mu), nu), (shift(x, nu), mu), (x, nu)]\n sg = 1\n for e in edges:\n sg *= centre(*e)\n curl = sum(orientation * XI.get(e, 0)\n for orientation, e in zip((1, 1, -1, -1), edges))\n if curl:\n counts[(sg, curl * curl)] += 1\npositive = sum(square * count for (sg, square), count in counts.items() if sg == 1)\nnegative = sum(square * count for (sg, square), count in counts.items() if sg == -1)\nassert (positive, negative) == (12, 14)\nassert sum(value * value for value in XI.values()) == 4\nprint(\'Exact four-link certificate on fine torus side 4\')\nprint(\'All 64 average numerators: zero\')\nprint(\'Nonzero plaquettes by (central sign, curl squared):\')\nfor (sg, square), count in sorted(counts.items()):\n print(f\' ({sg:+d}, {square}): {count}\')\nprint(f\'Positive sum: {positive}; negative sum: {negative}; signed sum: {positive-negative}\')\nprint(\'Q second derivative for HS-unit generator: -4\')\nprint(\'T(xi): 4; Q second derivative / T(xi): -1\')\nprint(\'Wilson action beta_W*Q/4 second derivative: -beta_W\')\n', 'd5/rough_hessian.py': '"""Search a centre-valued canonical fibre for an exact negative action direction.\n\nFloating eigensolver proposes an integer vector; all final constraints and\nsigned-curvature sums are checked with integer arithmetic. Q\'\'=2 sum sign*(d xi)^2\nfor a unit Hilbert--Schmidt generator. No sampling or continuum claim.\n"""\nfrom itertools import product, combinations\nimport json\nimport numpy as np\nfrom scipy.linalg import eigh\n\nn = 2\nfine = 2*n\nsites = list(product(range(fine), repeat=4))\ncoarse = list(product(range(n), repeat=4))\ndef shift(x, mu, step=1):\n out = list(x); out[mu] = (out[mu]+step)%fine; return tuple(out)\ndef tree(x, mu):\n return x[mu]%2 == 0 and all(x[nu]%2 == 0 for nu in range(mu+1,4))\ndef path(x, mu):\n return x[mu]%2 == 1 and all(x[nu]%2 == 0 for nu in range(4) if nu != mu)\nedges = [(x,mu) for x in sites for mu in range(4) if not tree(x,mu)]\nix = {e:i for i,e in enumerate(edges)}\nfree = [e for e in edges if not path(*e)]\nfidx = {e:i for i,e in enumerate(free)}\n# Integer matrix S2=2S avoids halves in the constraint section.\nS2 = np.zeros((len(edges),len(free)), dtype=np.int64)\nfor e,j in fidx.items(): S2[ix[e],j]=2\nfor y in coarse:\n for mu in range(4):\n origin=tuple(2*v for v in y)\n dp=shift(origin,mu)\n row=ix[(dp,mu)]\n for o in product(range(2),repeat=4):\n x=tuple(2*y[k]+o[k] for k in range(4))\n for e in ((x,mu),(shift(x,mu),mu)):\n if e in fidx: S2[row,fidx[e]] -= 1\n # The path link occurs twice in the average, hence these coefficients.\n# canonical c_y,mu=(-1)^(sum_{nu= -1e-8: raise RuntimeError(\'No negative direction found\')\nz=np.rint(100*vec[:,0]/max(abs(vec[:,0]))).astype(np.int64)\nxi=S2@z\n# All 64 exact linear average constraints, integer numerator of 16V.\nconstraints=[]\nfor y in coarse:\n for mu in range(4):\n c=0\n for o in product(range(2),repeat=4):\n x=tuple(2*y[k]+o[k] for k in range(4))\n for e in ((x,mu),(shift(x,mu),mu)):\n if e in ix: c+=int(xi[ix[e]])\n constraints.append(c)\nassert all(c==0 for c in constraints)\ndxi=D@xi\npositive=sum(int(t)**2 for t,s in zip(dxi,signs) if s==1)\nnegative=sum(int(t)**2 for t,s in zip(dxi,signs) if s==-1)\nassert positive-negative<0\nrecord={\'coarse_side\':n,\'generator_HS_norm\':1,\'z\':z.tolist(),\n \'positive_sum\':positive,\'negative_sum\':negative,\'signed_sum\':positive-negative,\n \'norm_squared\':sum(int(t)**2 for t in xi),\n \'all_average_numerators_zero\':True,\n \'meaning\':\'xi=S2*z; Q second derivative = 2*signed_sum\'}\nprint(json.dumps({k:v for k,v in record.items() if k!=\'z\'},sort_keys=True))\nprint(\'Discovery only; the sparse exact witness is in rough_certificate.py\')\n', 'd5/scales.py': '"""Item 5 scoping (D4_D8.md): the effective coupling at the coarsest scale of (D).\n\nHeuristic, one-loop running only. SU(2): beta_W(mu) = 2N/g^2 = 8 b0 log(mu/Lambda), b0 = 11N/(48 pi^2).\n(D) at physical size ell forces a gap >= log(1/alpha)/(2 ell) (paper, \'continuum step\').\nIf the true gap is m, then ell >= log(1/alpha)/(2m). The cube has n0 blocks per side,\nso the coarsest blocks have size ell/n0 and effective coupling beta_top = 8 b0 log(n0/(ell Lambda)).\n"""\nfrom math import log, pi\nN = 2\nb0 = 11*N/(48*pi**2)\nc = 8*b0\nprint(f"beta_W = {c:.4f} * log(mu/Lambda)")\nalpha = 0.9\nfor m_over_L in (1.0, 10.0, 100.0): # gap in units of Lambda (lattice vs MSbar differ by ~20)\n ell_L = log(1/alpha)/(2*m_over_L) # minimal ell*Lambda\n for n0, name in ((5.67e14, "chart C_G"), (2e15/alpha, "Gaussian constrained"), (None, "Gaussian all scales")):\n lg = log(n0) if n0 is not None else 827*log(10)-log(alpha)\n bt = c*(lg - log(ell_L))\n print(f"m/Lambda={m_over_L:6.1f} n0={name:22s} beta_top <= {bt:9.1f}")\nprint()\nfor thr, name in ((3.8e38, "chartdecay/fibrechart"), (3.8e97, "off-chart window"), (8.3e163, "islands")):\n print(f"threshold {name:22s} beta >= {thr:.1e}: needs log(n0/(ell Lambda)) >= {thr/c:.2e}")\n', 'd5/sf_constants.py': '"""Certified constants for smallfield.tex (mpmath.iv, 60 digits).\n\nc_2(lam,eta) = 24 log 1.957 + 73 log 14 + 109.5 (1 + log(15979 (1+1/eta) lam))\na_2(lam,kappa) = lam kappa^2 (1 - 216 (1+eta) (kappa\'/kappa)^2) - 8 log M - c_2(lam,eta)\nwith kappa\' = kappa/30, eta = 1, M = 1 + 2 (1 - 7 Lambda/8)^{-3} < 23621 (Lemma lem:averagedensity).\n"""\nfrom mpmath import iv, mp\niv.dps = 60\nM = iv.mpf(23621) # upper bound for M\nlogM = iv.log(M)\ndef c2(lam, eta):\n return 24*iv.log(iv.mpf(\'1.957\')) + 73*iv.log(iv.mpf(14)) + \\\n iv.mpf(\'109.5\')*(1 + iv.log(15979*(1 + 1/iv.mpf(eta))*lam))\ndef a2(lam, kap, ratio=30, eta=1):\n fac = 1 - 216*(1 + iv.mpf(eta))/iv.mpf(ratio)**2\n return lam*kap**2*fac - 8*logM - c2(lam, eta)\n# the rho of the proof: rho^2 = 1/(15978.08 (1+1/eta) lam); 2*216*8100/219\nprint("2*216*8100/219 <", repr(float(((iv.mpf(2*216*8100)/219)).b)), "<= 15979")\nassert (iv.mpf(2*216*8100)/219).b <= 15979\nprint("8 log M <", repr(float(((8*logM)).b)))\nprint("c_2(10^12,1) <", repr(float((c2(iv.mpf(10)**12, 1)).b)))\n# threshold lam* with a_2 >= 9, by bisection on the left end certified\ndef threshold(kap):\n kap = iv.mpf(kap)\n lo, hi = iv.mpf(100), iv.mpf(10)**40\n # a_2 increasing for lam > 109.5/(0.52 kap^2); start lo there\n lo = iv.mpf(max(100, float((iv.mpf(\'109.5\')/(iv.mpf(\'0.52\')*kap**2)).b)))\n assert a2(lo, kap).b < 9\n assert a2(hi, kap).a > 9\n for _ in range(400):\n mid = iv.mpf(((lo + hi)/2).mid)\n if a2(mid, kap).a > 9: hi = mid\n else: lo = mid\n if (hi - lo).b / hi.a < 1e-9: break\n return hi\nfor kap in [\'0.08\', \'1e-2\', \'1e-4\', \'1e-8\']:\n lam = threshold(kap)\n k = iv.mpf(kap)\n rho = 1/iv.sqrt(iv.mpf(\'15978.08\')*2*lam)\n # rho <= 9.32e-4 and rho <= (kappa-kappa\')/90\n assert rho.b <= 9.32e-4 and rho.b <= (k*29/30/90).a\n assert a2(lam, k).a > 9\n print("kappa=%s: a_2 >= 9 for lam >= %.10g; beta** = 4 lam <= %.7g; lam kappa^2 <= %.7g"\n % (kap, float(lam.b), float((4*lam).b), float((lam*k**2).b)))\n# Z_emptyset lower bound uses c_1 of thm:lfaction with rho^2 = 1/(11520(1+1/eta)lam); rho<=(kappa-kappa\')/90\n# holds when lam (kappa-kappa\')^2 >= 8100/11520\nprint("8100/11520 =", 8100/11520)\n', 'd5/sf_lattice.py': '"""Exact enumerations for the small-field block (smallfield.tex).\n\nBlocks B(y)=2y+{0,1}^4, tree gauge of Definition def:blockgauge. Variable\ngroups: I_y (17 active links inside B(y)), P_{y,mu} (8 private links of the\npair (y,mu)). All statements below are checked by exhaustive enumeration\n(integer arithmetic only).\n"""\nimport itertools, random\nD = 4\ndef off(x): return tuple(c % 2 for c in x)\ndef blk(x): return tuple(c // 2 for c in x)\ndef add(a, b): return tuple(i + j for i, j in zip(a, b))\ndef sub(a, b): return tuple(i - j for i, j in zip(a, b))\ndef e(m): return tuple(1 if i == m else 0 for i in range(D))\ndef linf(a, b): return max(abs(i - j) for i, j in zip(a, b))\nO16 = [tuple(o) for o in itertools.product((0, 1), repeat=D)]\n\ndef group(x, m):\n o = off(x); y = blk(x)\n if o[m] == 1: return (\'P\', y, m)\n if all(o[n] == 0 for n in range(m + 1, D)): return None # tree link\n return (\'I\', y)\n\ndef owned(y):\n for o in O16:\n x = add(tuple(2 * c for c in y), o)\n for m, n in itertools.combinations(range(D), 2):\n yield (x, m, n)\n\ndef links(p):\n x, m, n = p\n return [(x, m), (add(x, e(m)), n), (add(x, e(n)), m), (x, n)]\n\ndef fdeps(y):\n return {g for p in owned(y) for (z, k) in links(p) for g in [group(z, k)] if g}\n\n# ---- (1) the factor f_0 -------------------------------------------------\nZ = (0,) * D\nassert sum(1 for _ in owned(Z)) == 96\nf0 = fdeps(Z)\nexpect = {(\'I\', Z)} | {(\'P\', Z, m) for m in range(D)} \\\n | {(\'I\', e(n)) for n in range(D)} \\\n | {(\'P\', e(n), m) for n in range(D) for m in range(D) if m != n}\nassert f0 == expect, f0 ^ expect\nprint("(1) f_0 depends exactly on I_0, P_{0,mu}, I_{e_nu}, P_{e_nu,mu} (mu!=nu):",\n len(f0), "groups")\n# active links in each group\ncnt = {}\nfor y0 in [Z]:\n for o in O16:\n for m in range(D):\n g = group(o, m)\n if g: cnt[g[0]] = cnt.get(g[0], 0) + 1\nprint(" active links per block: inside", cnt[\'I\'], " private", cnt[\'P\'])\n\n# ---- (2) the cut-off averages -------------------------------------------\ndef vdeps(y, m):\n s = set()\n for o in O16:\n x = add(tuple(2 * c for c in y), o)\n for z in (x, add(x, e(m))):\n g = group(z, m)\n if g: s.add(g)\n return s\nfor m in range(D):\n v = vdeps(Z, m)\n assert v <= {(\'P\', Z, m), (\'I\', Z), (\'I\', e(m))} and (\'P\', Z, m) in v\nprint("(2) V_{y,mu} depends only on P_{y,mu}, I_y, I_{y+e_mu}")\n\n# ---- (3) the kernels -----------------------------------------------------\ndef dminus(X):\n return {sub(x, e(m)) for x in X for m in range(D)} - X\ndef dpairs_in(X):\n return {(sub(x, e(m)), m) for x in X for m in range(D) if sub(x, e(m)) not in X}\ndef integrated(X):\n s = {(\'I\', x) for x in X} | {(\'P\', x, m) for x in X for m in range(D)}\n s |= {(\'P\', z, m) for (z, m) in dpairs_in(X)}\n return s\ndef dsecond(X):\n dm = dminus(X)\n return {sub(sub(x, e(m)), e(n)) for x in X for m in range(D) for n in range(D)\n if m != n} - X - dm\ndef needed(X):\n """blocks w whose f_w involves a variable integrated in K_X"""\n integ = integrated(X)\n cands = {add(x, d) for x in X for d in itertools.product((-1, 0, 1), repeat=D)}\n return {w for w in cands if fdeps(w) & integ}\n\ndef check_kernel(X):\n X = set(X)\n hat = X | dminus(X) | dsecond(X)\n nd = needed(X)\n assert nd == hat, (sorted(nd ^ hat))\n # every block of hat lies in X + {0, -e_mu, -e_mu-e_nu}\n for w in hat:\n assert any(sub(x, w) in {Z} | {e(m) for m in range(D)} |\n {add(e(m), e(n)) for m in range(D) for n in range(D) if m != n}\n for x in X)\n integ = integrated(X)\n # factors in hat involve, besides integrated variables, only groups of blocks\n # within l_inf distance one of X, and no pair whose measure involves an\n # integrated inside variable is left outside\n outer_used = set().union(*(fdeps(w) for w in hat)) - integ\n for g in outer_used:\n assert min(linf(g[1], x) for x in X) <= 1\n if g[0] == \'P\':\n z, m = g[1], g[2]\n assert (\'I\', z) not in integ and (\'I\', add(z, e(m))) not in integ\n # moved plaquettes: owned by hat, contain an integrated link, have a vertex in B(X)\n nmov = 0\n for w in hat:\n for p in owned(w):\n gs = {group(z, k) for (z, k) in links(p)}\n if gs & integ:\n nmov += 1\n x0, m, n = p\n verts = [x0, add(x0, e(m)), add(x0, e(n)), add(add(x0, e(m)), e(n))]\n assert any(blk(v) in X for v in verts)\n # every plaquette of Pi(X) contains an integrated link\n for x in X:\n for p in owned(x):\n assert {group(z, k) for (z, k) in links(p)} & integ\n return hat, nmov, len(dpairs_in(X))\n\nhat, nmov, nin = check_kernel([Z])\nprint("(3) X={0}: |X^|=%d, |d^-X|=%d, |d^=X|=%d, pairs into X=%d, moved plaquettes=%d"\n % (len(hat), len(dminus({Z})), len(dsecond({Z})), nin, nmov))\n\ndef random_connected(n, rng):\n X = {Z}\n while len(X) < n:\n x = rng.choice(sorted(X))\n d = tuple(rng.choice((-1, 0, 1)) for _ in range(D))\n X.add(add(x, d))\n return X\nrng = random.Random(20261104)\nworst = 0\nfor trial in range(300):\n X = random_connected(rng.randint(1, 7), rng)\n hat, nmov, nin = check_kernel(X)\n worst = max(worst, nmov / len(X))\n assert nin <= 4 * len(X)\nprint(" 300 random l_inf-connected sets of 1..7 blocks: kernel factor set = X u d^-X u d^=X,"\n " moved plaquettes per block <= %.3f <= 384" % worst)\nassert worst <= 384\n\n# ---- (4) two components at distance >= 2 share no factor and no variable --\nfor trial in range(300):\n X1 = random_connected(rng.randint(1, 4), rng)\n shift = tuple(rng.choice((-6, -5, -4, -3, -2, 2, 3, 4, 5, 6)) if i == 0 else rng.randint(-2, 2)\n for i in range(D))\n X2 = {add(x, shift) for x in random_connected(rng.randint(1, 4), rng)}\n if min(linf(a, b) for a in X1 for b in X2) < 2: continue\n h1 = X1 | dminus(X1) | dsecond(X1); h2 = X2 | dminus(X2) | dsecond(X2)\n assert not (h1 & h2)\n assert not (integrated(X1) & integrated(X2))\n # a factor of one kernel never involves a variable integrated by the other\n for w in h1: assert not (fdeps(w) & integrated(X2))\n for w in h2: assert not (fdeps(w) & integrated(X1))\nprint("(4) components at l_inf distance >= 2: disjoint factor sets and variables (300 trials)")\nprint("all checks passed")\n', 'd5/sf_schur.py': '"""Exact rational computation for the obstruction (smallfield.tex).\n\nScalar linearised model on the W-fibre of Sec. ssec:largefields: real phi on\nthe active links with base in the blocks of W, phi = 0 on tree links and on all\nlinks off A_W; q(gamma) = min sum_{p in P_W} (dphi)_p^2 subject to\nV_{y,mu}(phi) = gamma_{y,mu} for y in W (Definition def:blockgauge).\nq(gamma) = gamma^T M gamma. We compute M exactly (python-flint fmpq_mat)\nfor W a row of n blocks along e_0 and report M_{AA}, M_{AB} for the coarse\nlinks A = (0, 1), B = ((n-1) e_0, 1).\n"""\nimport itertools, sys\nfrom fractions import Fraction\nimport flint\nD = 4\ndef off(x): return tuple(c % 2 for c in x)\ndef blk(x): return tuple(c // 2 for c in x)\ndef add(a, b): return tuple(i + j for i, j in zip(a, b))\ndef e(m): return tuple(1 if i == m else 0 for i in range(D))\nO16 = [tuple(o) for o in itertools.product((0, 1), repeat=D)]\ndef is_tree(x, m):\n o = off(x); return o[m] == 0 and all(o[n] == 0 for n in range(m + 1, D))\n\ndef model(n):\n W = [tuple([k, 0, 0, 0]) for k in range(n)]\n Wset = set(W)\n var = {}\n for y in W:\n for o in O16:\n x = add(tuple(2 * c for c in y), o)\n for m in range(D):\n if not is_tree(x, m):\n var[(x, m)] = len(var)\n assert len(var) == 49 * n\n # plaquettes containing a variable link\n plaq = set()\n for (x, m) in var:\n for nn in range(D):\n if nn == m: continue\n a, b = min(m, nn), max(m, nn)\n # plaquettes in plane {a,b} containing link (x,m): corner x or x - e_other\n other = nn\n for corner in (x, tuple(c - d for c, d in zip(x, e(other)))):\n plaq.add((corner, a, b))\n rows = []\n for (x, a, b) in plaq:\n L = [((x, a), 1), ((add(x, e(a)), b), 1), ((add(x, e(b)), a), -1), ((x, b), -1)]\n r = {}\n for l, s in L:\n if l in var: r[var[l]] = r.get(var[l], 0) + s\n rows.append(r)\n nv = len(var)\n # G = D^T D\n G = [[0] * nv for _ in range(nv)]\n for r in rows:\n for i, si in r.items():\n for j, sj in r.items():\n G[i][j] += si * sj\n # constraints, multiplied by 16\n cons = []\n for y in W:\n for m in range(D):\n c = {}\n for o in O16:\n x = add(tuple(2 * cc for cc in y), o)\n for z in (x, add(x, e(m))):\n if (z, m) in var: c[var[(z, m)]] = c.get(var[(z, m)], 0) + 1\n cons.append(((y, m), c))\n return var, rows, G, cons\n\ndef schur(n):\n var, rows, G, cons = model(n)\n nv, nc = len(var), len(cons)\n N = nv + nc\n K = flint.fmpq_mat(N, N)\n for i in range(nv):\n for j in range(nv):\n if G[i][j]: K[i, j] = 2 * G[i][j]\n for k, (_, c) in enumerate(cons):\n for i, s in c.items():\n K[nv + k, i] = s; K[i, nv + k] = s\n # right-hand sides: 16*gamma = unit vectors (constraint rows are 16 V)\n Rhs = flint.fmpq_mat(N, nc)\n for k in range(nc):\n Rhs[nv + k, k] = 16\n Sol = K.solve(Rhs)\n assert K * Sol == Rhs # exact rational solution of the KKT system\n # q(e_k) etc: phi^T G phi; M_{kl} = phi_k^T G phi_l\n phis = [[Sol[i, k] for i in range(nv)] for k in range(nc)]\n def form(a, b):\n s = flint.fmpq(0)\n for r in rows:\n da = sum((s_ * a[i] for i, s_ in r.items()), flint.fmpq(0))\n db = sum((s_ * b[i] for i, s_ in r.items()), flint.fmpq(0))\n s += da * db\n return s\n labels = [lab for lab, _ in cons]\n kA = labels.index(((0, 0, 0, 0), 1)); kB = labels.index(((n - 1, 0, 0, 0), 1))\n MAA = form(phis[kA], phis[kA]); MAB = form(phis[kA], phis[kB])\n # check the constraint and the stationarity are exact\n return len(var), len(rows), MAA, MAB\n\ndef dec(q, digits=8):\n # decimal rounding of an exact rational, sign and \'digits\' significant digits\n from fractions import Fraction\n f = Fraction(int(q.p), int(q.q))\n return \'%.*e\' % (digits - 1, f)\n\nif __name__ == "__main__":\n nmax = int(sys.argv[1]) if len(sys.argv) > 1 else 7\n print("Row of n blocks along e_0; A=(0,1), B=((n-1)e_0,1); exact rationals, rounded:")\n for n in range(1, nmax + 1):\n nv, npl, MAA, MAB = schur(n)\n print("n=%d: |A_W|=%d, n_P=%d, M_AA=%s, M_AB=%s" % (n, nv, npl, dec(MAA), dec(MAB)),\n flush=True)\n if n == 4:\n print(" n=4 exact M_AB =", MAB)\n assert MAB < 0\n\n', 'd5/slab_energy_constants.py': '"""Certified constants of Proposition prop:energybeta (ssec:slabenergy); A, B, D here are K_1, K_2, K_3 of the paper.\n\nInterval arithmetic with mpmath.iv at 60 decimal digits. With lambda = 1/5 and\nc = 5/8 the per-plaquette energy bound of the proposition reads\n eps <= ( A + B/L^4 + (15/16)(1/L + 1/(3L^4)) log beta + D/beta ) / beta\nfor beta >= 1 and L >= 2, where\n A = (5/4) K,\n K = (1/4)log(2/pi) - (3/4)log(lam) - (1/2)log(2/(3pi)) - (3/4)log(c) + (6/5)c,\n B = (5/24)( -log(2/(3pi)) - (3/2)log(c) ),\n D = (5/4)(1 + 1/48) * (c/6) / (1 - c/6).\nThe script also checks the sign conditions used in the proof and scans the\nchoice of lambda and c on a grid (floating point, only to report that the\nchosen pair is near the optimum; no statement rests on the scan).\n"""\nfrom mpmath import iv, mp, mpf, log, pi\niv.dps = 60\nmp.dps = 30\n\nlam = iv.mpf(1) / 5\nc = iv.mpf(5) / 8\nPI = iv.pi\nL = iv.log\n\ndef show(name, x):\n print(f"{name}: {iv.nstr(x, 15)}")\n\nhalf_log_2pi = L(2 / PI) / 2\nball = L(2 / (3 * PI))\nK = half_log_2pi / 2 - 3 * L(lam) / 4 - ball / 2 - 3 * L(c) / 4 + 6 * c / 5\nA = 5 * K / 4\nB = 5 * (-ball - 3 * L(c) / 2) / 24\ny = c / 6 # delta^2/6 at beta = 1, the largest value\nD = 5 * (1 + iv.mpf(1) / 48) / 4 * y / (1 - y)\ndropped = half_log_2pi - 3 * L(lam) / 2 # coefficient of the dropped 1/L term\n\nshow("K", K)\nshow("A", A)\nshow("B", B)\nshow("D", D)\nshow("(1/2)log(2/pi) - (3/2)log(lambda) [must be >= 0]", dropped)\nshow("delta^2 at beta=1 = c [must be <= pi^2/4]", c)\nshow("pi^2/4", PI**2 / 4)\nassert dropped.a > 0\nassert c.b < (PI**2 / 4).a\nassert A.b < mpf("3.7148") and B.b < mpf("0.4699") and D.b < mpf("0.149")\nprint("certified: A < 3.7148, B < 0.4699, D < 0.149")\n\n# Gaussian heuristic comparison constant (not used in any statement)\ndef Kf(l, cc):\n return (log(2 / pi) / 4 - 0.75 * log(l) - 0.5 * log(2 / (3 * pi))\n - 0.75 * log(cc) + 1.2 * cc) / (1 - l)\nbest = min((Kf(l / 1000, cc / 1000), l / 1000, cc / 1000)\n for l in range(20, 900, 5) for cc in range(100, 2000, 5))\nprint("grid minimum of A over (lambda, c), floating point:", best)\n', 'd5/touching_checks.py': '"""Computation checks for TOUCHING_CHART.md; not a Hessian certificate.\n\nRun with Python\'s standard library. The geometric proof is in the note;\nthese finite enumerations check offsets and periodic separation cases.\n"""\nfrom itertools import product\nfrom math import asin, sin, sqrt, pi\n\nalpha = 2 * asin(1 / (2 * sqrt(2)))\na = 7 * alpha / (8 * sin(alpha))\nassert a < 0.9561\nassert 46 * a < 44\nassert 2 * a / (1 - a) < 44\nassert 8 * pi * 1e-8 + 46e-4 < 0.01\n\n# One coordinate: a vertex is in a neighbouring block, and a plaquette\n# base can be the vertex itself or one step behind it.\nbases = {2 * block + offset - backward\n for block in (-1, 0, 1)\n for offset in (0, 1) for backward in (0, 1)}\nassert bases == set(range(-3, 4))\nassert len(list(product(bases, repeat=4))) == 2401\n\n# On a periodic coarse cycle, shared fine-base boxes force distance <=3.\n# Taking products gives the four-dimensional separation statement.\nfor side in range(1, 65):\n origin = {v % (2 * side) for v in bases}\n for y in range(side):\n shifted = {(2 * y + v) % (2 * side) for v in bases}\n if origin & shifted:\n assert min(y, side - y) <= 3\n\nprint(f\'a = {a:.12f}\')\nprint(f\'46a = {46*a:.12f} < 44\')\nprint(f\'2a/(1-a) = {2*a/(1-a):.12f} < 44\')\nprint(\'M = Dsep = 2401; 6M = 14406\')\nprint(\'Offset enumeration and periodic separation (sides 1..64): passed\')\nprint(\'No Hessian, label-domain, or island-threshold claim is checked here.\')\n', 'd5/witness_geometry.py': '"""Brute-force check of the witness-box counts M_j=(17 2^j-4)^4, H_j (per coordinate),\nand the composed threshold for the chart-calm choice rho=1e-10 (eta=9.2e-9, r=4.3e-9)."""\nfrom composed_threshold import composed, kstar, witness_counts\nfrom mpmath import mpf\nfor j in range(1, 7):\n d = 3*(2**j - 1) # spreading, Theorem defectscales(ii), fine units\n corners = set()\n for xp in range(-5, 6): # scale-j witness corner, Theorem islandthreshold proof (box of side 11)\n lo, hi = 2**j*xp - d, 2**j*xp + 2**j + d # fine coordinates reachable from the closed plaquette P\n for x in range(lo - 5, hi + 5):\n if x + 1 >= lo and x <= hi: # [x,x+1] meets [lo,hi]\n corners.add(x)\n side = max(corners) - min(corners) + 1\n # H: a fine corner x lies in the box of y iff x - 2^{j+1} y in corners\n step = 2**(j+1)\n H1 = max(sum(1 for y in range(-30, 31) if (x - step*y) in corners) for x in range(step))\n M, H = witness_counts(j)\n print(f"j={j}: corner range [{min(corners)},{max(corners)}], side={side} (formula {17*2**j-4}), per-coordinate overlap {H1} -> H_j={H1**4} (formula {H})")\n assert side**4 == M and H1**4 == H and min(corners) == -8*2**j+2 and max(corners) == 9*2**j-3\nprint()\nprint("chart-calm labels rho=1e-10 (eta=9.2e-9<=1e-8), s=5:")\nfor j in range(0, 9):\n M,H,lq,rho0,b = composed(j, 5, rho=mpf(\'1e-10\'))\n k,_ = kstar(b)\n print(f" j={j}: beta*_j={float(b):.4e} 16^-j beta*_j={float(b/16**j):.4e} k_*(beta*_j)={k} k_*-j={k-j}")\n', 'd5/witness_radius.py': '"""Certified SU(2) constants of prop:smallframessharp (mpmath.iv). Usage: python3 witness_radius.py\nConventions: angle(g) in [0,pi] with eigenvalues e^{+-i angle}; delta(g,I)=2*sqrt2*sin(angle/2);\n||log g||=sqrt2*angle; p = psi_0(kappa) = 2*arcsin(kappa/(2*sqrt2)), the largest plaquette angle."""\nfrom mpmath import iv, mp\niv.dps = 30; mp.dps = 30\nI = iv.mpf; s2 = iv.sqrt(I(2)); pi = iv.pi\ndef asin(x):\n """certified enclosure of arcsin on [0,1): checked through iv.sin (increasing)."""\n x = I(x); eps = mp.mpf(10)**-25\n lo = mp.asin(x.a) - eps; hi = mp.asin(x.b) + eps\n assert iv.sin(I(lo)).b <= x.a and iv.sin(I(hi)).a >= x.b and hi < mp.pi/2\n return I([lo, hi])\niv.asin = asin\ndef ang(kappa): return 2*iv.asin(I(kappa)/(2*s2))\ndef show(name, x): print(f"{name}: [{mp.nstr(mp.mpf(x.a),10)}, {mp.nstr(mp.mpf(x.b),10)}]")\n# 1. sharp threshold of smallframes (iv): 2*sqrt2*sin(3p) = 1/2\npc = iv.asin(1/(4*s2))/3; kc = 2*s2*iv.sin(pc/2)\nshow("psi_c", pc); show("kappa_c", kc)\nassert kc.a > I(1)/12\n# 2. K_iv(kappa)/kappa <= (p/kappa)*G(p), both factors increasing; evaluate at kappa_c\ndef G(p):\n a6, a12 = 6*p, 12*p\n psih = a6/2*iv.exp(a6) # >= (e^a-1-a)/a >= sup|Psi(i t)-1|, |t|<=a\n phih = a12/2 + I(\'0.09\')*a12**2 # >= sup|Phi(i t)-1|, |t|<=a<=1 (paper\'s Bernoulli bound)\n assert a12.b <= 1\n return 2*3 + 2*6 + (1+iv.sqrt(I(3))/4)*(psih*(1+phih)+phih) / p * 1 + iv.sqrt(8*(18*p)**2+8*(6*p)**2)/16/p\npkc = ang(kc.b)\nratio = (pkc/I(kc.a)) * G(pkc)\nshow("sup_{kappa<=kappa_c} K_iv(kappa)/kappa <=", ratio)\nshow("limit coefficient as kappa->0 (G(0+)/sqrt2)", G(ang(I(\'1e-20\')))/s2)\nassert ratio.b < 260\nshow("p/kappa at kappa_c", pkc/I(kc.a))\n# 3. coarse witness and link witness ratios at kappa_c (delta <= sqrt2*n*p <= c*kappa)\nr = pkc/I(kc.a)\nshow("link witness 12*sqrt2*p/kappa", 12*s2*r); show("coarse plaquette 16*sqrt2*p/kappa", 16*s2*r)\nassert (8*pkc).b < pi.a/2\n# 4. explicit example: L=32, n=10, phi=2*pi*n/L^2\nphi = 2*pi*10/I(1024)\nkap = 2*s2*iv.sin(phi/2); d6 = 2*s2*iv.sin(3*phi); chi = 2-2*d6\nshow("example kappa", kap); show("example max delta(P_x,v)", d6); show("example chi", chi)\nassert d6.a > 0.5 and chi.b < 1 and (48*phi).b < pi.a\nshow("example 1/16 sum of angles of w_x = 3*phi (angle of M)", 3*phi)\n# 5. branchbound for SU(2): ||DF|| <= (7/8)*x/sin x, x = 8*sqrt2*r\nrr = I(1)/32; x = 8*s2*rr; c = I(7)/8*x/iv.sin(x); show("branchbound contraction at r=1/32", c); assert c.b < 0.9\n# 6. Cauchy chain of prop:explicitconstants\ndef chain(a, R, x0=I(\'1e-3\')):\n e0 = a + 3*x0; ph = iv.exp(R)-1; ps = (1+ph)**3-1; d = ps/(1-e0-ps); et = (1+ph)*iv.exp(d)-1\n g0 = x0 + 3*x0/(1-e0); assert (e0+ps).b < 1 and (g0+et).b < 1\n return et/(1-g0-et)\nfor a in (I(\'1e-6\'), I(\'6e-4\')):\n print("a =", mp.nstr(a.a,3))\n for m, R in ((1, I(\'1e-3\')), (2, I(\'0.05\')), (3, I(\'0.07\'))):\n S = chain(a, R); show(f" m={m}: m! S(R)/R^m", iv.factorial(m)*S/R**m)\n e0 = a + 3*I(\'1e-3\'); ph = iv.exp(I(\'0.1\'))-1; ps = (1+ph)**3-1; d = ps/(1-e0-ps); et = (1+ph)*iv.exp(d)-1\n g0 = I(\'1e-3\') + 3*I(\'1e-3\')/(1-e0)\n show(" |z|<0.1: e0+psi", e0+ps); show(" gamma0+eta", g0+et); show(" gamma0", g0)\n assert (e0+ps).b < 0.36 and (g0+et).b < 0.91 and g0.b < 0.0041\nc2 = s2*I(307); show("c_2 = sqrt2*307", c2)\n# 7. radius of fibrechart (iv) with c_2 in (i),(ii): s/4+(5.4e4+9000 c_2)kappa\' <= 1/195, s<=kappa\'/6\nRiv = (I(1)/195)/(I(\'5.4e4\')+9000*I(435)+I(1)/24); show("R_iv (kappa+6s <=)", Riv)\nRpaper = (I(1)/195)/(4*10**5*I(\'2.13e4\')); show("paper: kappa+s <=", Rpaper)\n# 8. smallfibre (i) literal constant: (1+k)^2/(1-1.31e6 k (1+k)^2) <= 1+1.4e6 k\ndef ok(k):\n k = I(k); den = 1-I(\'1.31e6\')*k*(1+k)**2\n return den.a > 0 and ((1+k)**2/den).b <= (1+I(\'1.4e6\')*k).a\nlo, hi = mp.mpf(\'1e-9\'), mp.mpf(\'1e-6\')\nassert ok(lo) and not ok(hi)\nfor _ in range(80):\n m = (lo+hi)/2\n if ok(m): lo = m\n else: hi = m\nprint("smallfibre(i) literal 52(1+1.4e6 k) holds (paper\'s proof) up to k =", mp.nstr(lo,6))\n# 9. flat background: sup ||D^2 c(0)[Y,Y]|| over N(Y)=1, mu=0: explicit Y attains 1/16\nprint("flat second derivative lower bound: 1/16 = 0.0625 (exact, prop:flatsecond); route bound kappa\' <=",\n mp.nstr(((I(1)/195)/(12*I(\'10.6\')*34*2*I(\'1.03\')*I(1)/16)).b, 6))\n', 'effective_locality.py': '"""Checks of Theorem "effectivelocal": the effective forms S_k of the block-constrained\nquadratic approximation are S_k(w) = sum_P int K_P |F_P^|^2, with\nK_P = prod_{s not in P} atilde_s / Y the functions of the paper (Feynman gauge, the pole of the\nfine propagator cancelled), and the constants of the proof of part (ii).\n(A) K_P against the constrained minimum computed directly from the plaquette form (pure gauges\n projected out, no Feynman gauge), at random momenta, k = 1, 2, 3.\n(B) K_P(0) = 1, K_P > 0 and Y >= (2/pi)^32 on a grid of the real torus.\n(C) the bounds of Step 4 at random points of the strip |Im theta| <= 1/2, k = 1, 2, 3.\n(D) the arithmetic of Step 4: c_1, the bound for r, M, eta = 1e-36, C = 1e26.\n(E) floating point (no statement rests on it): the decay of the kernels of K_P by\n l1 distance and the range of K_P on a grid of 12^4 momenta, k = 1, 2, 3.\nRun: python3 effective_locality.py (about eight minutes). Needs numpy."""\nimport numpy as np, itertools, math\nPL = [(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)]\npassed = failed = 0\n\n\ndef check(name, ok):\n global passed, failed\n print((\'PASS \' if ok else \'FAIL \') + name)\n if ok:\n passed += 1\n else:\n failed += 1\n\n\ndef DL(t, L):\n t = np.asarray(t, complex)\n return sum(np.exp(1j * t * j) for j in range(L)) / L\n\n\ndef sharp2(f, t, L):\n """f f^sharp at t: the analytic continuation of |f|^2."""\n return f(t, L) * np.conj(f(np.conj(t), L))\n\n\ndef blocks(th, k, want_parts=False):\n L = 2 ** k\n th = np.asarray(th, complex)\n r = np.zeros(th.shape[:-1] + (4,), complex)\n minre = np.inf\n for n in itertools.product(range(L), repeat=4):\n q = (th + 2 * np.pi * np.array(n)) / L\n q = q - 2 * np.pi * np.round(q.real / (2 * np.pi))\n D2 = sharp2(DL, q, L)\n Psi2 = np.prod(D2, -1)\n eps = L * L * np.sum(2 - 2 * np.cos(q), -1)\n if not any(n):\n Psi0, D0, eh = Psi2, D2, eps\n else:\n r += Psi2[..., None] * D2 / eps[..., None]\n s = L * q.real\n minre = min(minre, np.min(eps.real / np.sum(s * s, -1)))\n E2 = (np.exp(1j * th) - 1) * (np.exp(-1j * th) - 1)\n A = Psi0[..., None] * D0\n at = A + eh[..., None] * r\n Y = Psi0 ** 3 * np.prod(D0, -1)\n for s in range(4):\n oth = [t for t in range(4) if t != s]\n for m in range(1, 4):\n for J in itertools.combinations(oth, m):\n term = eh ** (m - 1)\n for t in oth:\n term = term * (r[..., t] if t in J else A[..., t])\n Y = Y + E2[..., s] * term\n if want_parts:\n return at, Y, r, A, eh, minre\n return at, Y\n\n\ndef K(th, k):\n at, Y = blocks(th, k)\n return np.stack([np.prod([at[..., s] for s in range(4) if s not in P], 0) / Y for P in PL], -1)\n\n\ndef S_from_K(th, k):\n KK = K(th, k)\n E = np.exp(1j * np.asarray(th, complex)) - 1\n out = np.zeros(E.shape[:-1] + (4, 4), complex)\n for i, (l, m) in enumerate(PL):\n c = np.zeros(E.shape, complex)\n c[..., m] = E[..., l]\n c[..., l] = -E[..., m]\n out += KK[..., i][..., None, None] * np.conj(c)[..., :, None] * c[..., None, :]\n return out\n\n\ndef S_direct(th, k):\n """min Q at one coarse momentum from the plaquette form itself: the fine field at the\n L^4 aliases, the constraint L^-4 sum_n c(theta_n) x_n = w, pure gauges projected out."""\n L = 2 ** k\n th = np.asarray(th, float)\n G = np.zeros((4, 4), complex)\n for n in itertools.product(range(L), repeat=4):\n q = (th + 2 * np.pi * np.array(n)) / L\n e = np.exp(1j * q) - 1\n Qm = np.sum(abs(e) ** 2) * np.eye(4) - np.outer(np.conj(e), e).T\n ee = np.outer(e, np.conj(e))\n Minv = np.linalg.inv(Qm + ee) - ee / np.sum(abs(e) ** 2) ** 2\n c = L * np.prod(DL(q, L)) * DL(q, L)\n G += (c[:, None] * Minv * np.conj(c)[None, :]) / L ** 4\n b = np.exp(1j * th) - 1\n P = np.eye(4) - np.outer(b, np.conj(b)) / np.vdot(b, b)\n # minimum over w + C b of z^* G^+ z restricted: S = (P G P)^+ on the complement of b\n return np.linalg.pinv(P @ G @ P, rcond=1e-12)\n\n\ndef main():\n global passed, failed\n rng = np.random.default_rng(7)\n # (A)\n for k in (1, 2, 3):\n pts = rng.uniform(-np.pi, np.pi, (6 if k < 3 else 3, 4))\n err = max(np.abs(S_from_K(p, k) - S_direct(p, k)).max() / np.abs(S_direct(p, k)).max() for p in pts)\n check(\'(A) k=%d: sum_P K_P c_P^* c_P equals the constrained minimum (rel. err %.1e)\' % (k, err), err < 1e-8)\n # (B)\n N = 8\n xs = np.linspace(-np.pi, np.pi, N)\n X = np.stack(np.meshgrid(xs, xs, xs, xs, indexing=\'ij\'), -1).reshape(-1, 4)\n for k in (1, 2, 3):\n at, Y = blocks(np.zeros(4), k)\n K0 = np.array([np.prod([at[s] for s in range(4) if s not in P]) / Y for P in PL])\n check(\'(B) k=%d: K_P(0) = 1\' % k, np.abs(K0 - 1).max() < 1e-12)\n at, Y = blocks(X, k)\n KK = K(X, k)\n check(\'(B) k=%d: K_P real and positive, Y >= (2/pi)^32 on a grid (min Y %.3g)\' % (k, Y.real.min()),\n np.abs(KK.imag).max() < 1e-9 and KK.real.min() > 0 and Y.real.min() >= (2 / np.pi) ** 32)\n # (C)\n for k in (1, 2, 3):\n pts = rng.uniform(-np.pi, np.pi, (300, 4)) + 0.5j * rng.uniform(-1, 1, (300, 4))\n at, Y, r, A, eh, minre = blocks(pts, k, True)\n ok = (np.abs(r).max() < 2.2e7 and np.abs(Y).max() < 1e28 and np.abs(at).max() < 1.6e9\n and np.abs(eh).max() < 70 and np.abs(A).max() <= math.e ** 5 and minre >= 0.28)\n check(\'(C) k=%d: strip bounds |r|<2.2e7, |Y|<1e28, |atilde|<1.6e9, |eps^|<70, Re L^2 eps_n >= 0.28|Re s|^2\'\n \' (max|r| %.3g, min ratio %.3f)\' % (k, np.abs(r).max(), minre), ok)\n # (D)\n c1 = (math.exp(0.5) + 1) * math.exp(0.25) * math.pi / 2\n rb = c1 ** 10 / (0.28 * math.pi ** 2) * (4 / 3) ** 4\n eh = 4 * (math.pi ** 2 + 0.25) * math.exp(0.5)\n EE = (math.exp(0.5) + 1) ** 2\n A = math.e ** 5\n M = math.e ** 16 + 4 * EE * (3 * rb * A ** 2 + 3 * eh * rb ** 2 * A + eh ** 2 * rb ** 3)\n low = (2 / math.pi) ** 32\n eta, C = 1e-36, 1e26\n check(\'(D) c1 = %.4f < 5.35, r bound %.3g < 2.2e7, M = %.3g <= 1e28\' % (c1, rb, M),\n c1 < 5.35 and rb < 2.2e7 and M <= 1e28 and eh < 70 and EE < 7.1)\n check(\'(D) 16 eta M <= (2/pi)^32/2 and (A + 70 r)^2 / ((2/pi)^32/2) = %.3g <= C\' % ((A + 70 * 2.2e7) ** 2 / (low / 2)),\n 16 * eta * 1e28 <= low / 2 and A + 70 * 2.2e7 < 1.6e9 and (1.6e9) ** 2 / (low / 2) <= C)\n # (E)\n N = 12\n js = np.arange(N) * 2 * np.pi / N\n X = np.stack(np.meshgrid(js, js, js, js, indexing=\'ij\'), -1).reshape(-1, 4)\n for k in (1, 2, 3):\n at, Y = blocks(X, k)\n KP = (np.prod(at[:, 2:], -1) / Y).real\n Kr = np.fft.ifftn(KP.reshape((N,) * 4)).real\n rr = np.indices((N,) * 4)\n rr = np.minimum(rr, N - rr).sum(0)\n mag = [np.abs(Kr)[rr == d].max() for d in range(6)]\n fac = [mag[d + 1] / mag[d] for d in range(1, 5)]\n print(\' k=%d: K_P in [%.3f, %.2f]; max|kernel| by l1 distance %s; factors %s\'\n % (k, KP.min(), KP.max(), \' \'.join(\'%.3g\' % m for m in mag), \' \'.join(\'%.3f\' % f for f in fac)))\n print(\'%d checks passed, %d failed\' % (passed, failed))\n\n\nif __name__ == \'__main__\':\n main()\n', 'effective_symbol.py': '"""Floating-point symbol of the effective forms S_k(w) = inf{Q(phi) : V^(k)(phi) = w}\nof the block-constrained quadratic approximation, for k = 1, 2, 3, on a half-shifted grid\nof 12^4 coarse momenta: the k-fold averages are the straight-path averages over blocks of\nside L = 2^k (Lemma "straightpaths"), the constraint is exact, and the pure gauges are\nprojected out. Prints the range of S_k/Q_k on curvatures and the decay of the kernel of S_k\nby coarse l-infinity distance. The paper states these values as floating-point observations\nonly; no statement rests on them. Run: python3 effective_symbol.py (about six minutes).\nNeeds numpy."""\nimport numpy as np, itertools\ndef Mmat(a):\n # a: (...,4) complex; Q = sum_{muqi\',Gi,b)\n S=Gi-Gb[:,:,None]*np.conj(Gb)[:,None,:]/np.einsum(\'qi,qi->q\',np.conj(b),Gb)[:,None,None]\n return Q,S,b\nif __name__==\'__main__\':\n N=12\n for k in (1,2,3):\n Q,S,b=symbol(k,N); L4=16**k\n S=S*L4 # the form in coarse-lattice units\n gauge=np.max(abs(np.einsum(\'qij,qj->qi\',S,b)))\n M1=Mmat(b); ev=[]\n for i in range(len(Q)):\n w,V=np.linalg.eigh(M1[i]); P=V[:,w>1e-9]\n ev+=list(np.linalg.eigvals(np.linalg.solve(np.diag(w[w>1e-9]),P.conj().T@S[i]@P)).real)\n K=np.fft.ifftn(S.reshape(N,N,N,N,4,4),axes=(0,1,2,3))\n r=np.indices((N,)*4); r=np.minimum(r,N-r); rinf=r.max(0)\n mag=[np.abs(K).max((-1,-2))[rinf==d].max() for d in range(N//2+1)]\n print(\'k = %d: S_k vanishes on gradients (%.1e); S_k/Q_k on curvatures in [%.3f, %.2f]\' % (k,gauge,min(ev),max(ev)))\n print(\' kernel by l-infinity distance:\', \' \'.join(\'%.3g\' % m for m in mag[:6]),\n \'; ratio %.3f\' % (mag[4]/mag[3]))\n', 'eps_mc.py': '"""Monte Carlo estimate of eps_V for SU(2) in the forest gauge.\n\neps_V(beta) is the mean chordal distance from the identity of the links of the\ncube V of side n under the gauge-fixed measure with the identity outside V.\nThe theorem on what the cube estimate requires says that D(n, alpha) forces\neps_V >= (1 - alpha) D / 3 = 2 (1 - alpha) / 3. This script samples the\nmeasure by heat bath and prints eps_V; a value well above 2/3 means that this\nnecessary condition excludes nothing at that coupling and size.\n\nRun: python3 eps_mc.py --beta 2.3 --n 6 [--chains 4 --therm 300 --sweeps 300]\nPrints one line per run; nothing in the paper rests on it.\n"""\nimport argparse\nimport numpy as np\nfrom influence_mc import Box, SIGMA\n\n\ndef main():\n ap = argparse.ArgumentParser()\n ap.add_argument("--beta", type=float, required=True, help="beta_W")\n ap.add_argument("--n", type=int, required=True)\n ap.add_argument("--chains", type=int, default=4)\n ap.add_argument("--therm", type=int, default=300)\n ap.add_argument("--sweeps", type=int, default=300)\n ap.add_argument("--seed", type=int, default=1)\n a = ap.parse_args()\n rng = np.random.default_rng(a.seed)\n n, P = a.n, a.n + 4\n idx = np.indices((P,) * 4)\n incube = np.ones((P,) * 4, bool)\n for d in range(4):\n incube &= (idx[d] >= 2) & (idx[d] < 2 + n)\n V = np.stack([(SIGMA[tuple(idx % 2)] != mu) & incube for mu in range(4)])\n box = Box(P, a.chains, rng)\n one = np.array([1.0, 0.0, 0.0, 0.0])\n series = []\n for t in range(a.therm + a.sweeps):\n box.heatbath(a.beta, rng, mask_extra=V)\n if t >= a.therm:\n d = np.linalg.norm(box.U - one, axis=-1) # (B, 4, P, P, P, P)\n series.append((d * V[None]).sum(axis=(1, 2, 3, 4, 5)) / V.sum())\n s = np.array(series) # (sweeps, chains)\n per_chain = s.mean(axis=0)\n half = len(s) // 2\n print(f"beta_W={a.beta} n={n} |V|={int(V.sum())} eps_V={per_chain.mean():.4f} "\n f"(chains sd {per_chain.std():.4f}, late-minus-early "\n f"{s[half:].mean() - s[:half].mean():+.4f}) threshold 2/3", flush=True)\n\n\nif __name__ == "__main__":\n main()\n', 'every_fibre.py': '"""Checks of the aligned field (lemma alignedfield) and of the Peierls bound on\nevery fibre (proposition everyfibre), for SU(2).\n\nA run of n blocks y_1, ..., y_n in direction mu, with y_n + e_mu outside W:\neach pair has its path link l_0 = g, the links u_a = (x_a, mu) inside its\nblock (tree links, equal to I, when a_nu = 0 for every nu > mu), the private\nlinks l_a, and w_a = u_a of the next block, fixed and arbitrary after y_n.\nThe script\n(A) builds the aligned field for random values of the averages and random\n fixed links, in the four directions, and checks that every v_x equals I\n and that every average takes its prescribed value;\n(B) on regular backgrounds with Haar random links inside the blocks and the\n sites of the averages within 1/4 of I, perturbs the links other than the\n path links by at most rho and checks that the iteration l -> c exp(-N(l))\n stays within 44 rho of the path link, keeps every site within 1/2 of I\n and solves the constraint, and that |det dV/dl_0| <= 1.957^3.\nDouble precision; the proofs in the paper are by hand.\nUsage: python3 every_fibre.py\n"""\nimport itertools\nimport numpy as np\nfrom scipy.linalg import expm, logm\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append(bool(ok))\n print(("PASS " if ok else "FAIL ") + name)\n\n\nS = [np.array(m, complex) for m in ([[0, 1], [-1, 0]], [[0, 1j], [1j, 0]], [[1j, 0], [0, -1j]])]\nB = [s / np.sqrt(2) for s in S]\nI2 = np.eye(2, dtype=complex)\n\n\ndef alg(c):\n return sum(ci * b for ci, b in zip(c, B))\n\n\ndef coords(X):\n return np.array([np.real(np.trace(b.conj().T @ X)) for b in B])\n\n\ndef haar(rng):\n q = rng.normal(size=4); q /= np.linalg.norm(q)\n return np.array([[q[0] + 1j * q[1], q[2] + 1j * q[3]], [-q[2] + 1j * q[3], q[0] - 1j * q[1]]])\n\n\ndef lg(g):\n X = logm(g)\n return (X - X.conj().T) / 2\n\n\ndef dist(a, b):\n return np.linalg.norm(lg(a.conj().T @ b))\n\n\ndef delta(v):\n return np.linalg.norm(v - I2)\n\n\ndef near(rng, s):\n z = rng.normal(size=3)\n return expm(alg(z / np.linalg.norm(z)) * s * rng.uniform())\n\n\nALPHA = 2 * np.arcsin(1 / (2 * np.sqrt(2)))\nLAM = ALPHA / np.sin(ALPHA)\nK7 = 7 * LAM / 8\nOFFS = list(itertools.product((0, 1), repeat=3)) # transverse offsets a\n\n\ndef is_tree(a, mu):\n """u_a = (x_a, mu) with o_mu = 0 is a tree link iff o_nu = 0 for nu > mu."""\n others = [nu for nu in range(4) if nu != mu]\n return all(a[i] == 0 for i, nu in enumerate(others) if nu > mu)\n\n\ndef sites(g, u, l, w):\n """the sixteen v_x of one pair; u, l, w indexed by the offsets a."""\n vs = []\n for a in OFFS:\n vs += [g.conj().T @ u[a] @ l[a], g.conj().T @ l[a] @ w[a]]\n return vs\n\n\ndef average(g, u, l, w):\n vs = sites(g, u, l, w)\n m = max(delta(v) for v in vs)\n chi = min(1.0, max(0.0, 2 - 2 * m))\n N = sum(lg(v) for v in vs) / 16 if chi > 0 else 0 * I2\n return g @ expm(chi * N), vs\n\n\n# (A) the aligned field\nworst_v, worst_c = 0.0, 0.0\nrng = np.random.default_rng(11)\nfor mu in range(4):\n for t in range(25):\n n = rng.integers(1, 5)\n c = [haar(rng) for _ in range(n)]\n w_end = {a: (I2 if is_tree(a, mu) else haar(rng)) for a in OFFS}\n u, l = [None] * n, [None] * n\n w_next = w_end\n for j in range(n - 1, -1, -1):\n g = c[j]\n u[j], l[j] = {}, {}\n for a in OFFS:\n if is_tree(a, mu):\n u[j][a], l[j][a] = I2, g\n else:\n l[j][a] = g @ w_next[a].conj().T\n u[j][a] = g @ w_next[a] @ g.conj().T\n w_next = u[j]\n for j in range(n):\n w = u[j + 1] if j + 1 < n else w_end\n V, vs = average(l[j][(0, 0, 0)], u[j], l[j], w)\n worst_v = max(worst_v, max(delta(v) for v in vs))\n worst_c = max(worst_c, np.linalg.norm(V - c[j]))\n assert np.allclose(u[j][(0, 0, 0)], I2)\nprint(f"aligned fields: largest delta(v_x, I) {worst_v:.1e}, largest |V - c| {worst_c:.1e}")\ncheck("the aligned field has v_x = I at every site and the prescribed averages",\n worst_v < 1e-12 and worst_c < 1e-12)\n\n# (B) regular backgrounds with large links inside the blocks\nworst_ratio, worst_site, max_det, conv, tested = 0.0, 0.0, 0.0, True, 0\nmu = 0\nfor t in range(200):\n g0 = haar(rng)\n u = {a: (I2 if is_tree(a, mu) else haar(rng)) for a in OFFS}\n w = {a: (I2 if is_tree(a, mu) else haar(rng)) for a in OFFS}\n # private links with v_{x_a}, v_{x\'_a} within 1/4 of I\n l = {}\n for a in OFFS:\n if a == (0, 0, 0):\n l[a] = g0\n else:\n l[a] = u[a].conj().T @ g0 @ near(rng, 0.12)\n for a in OFFS:\n if a != (0, 0, 0):\n # adjust w so that v_{x\'_a} is also near I\n w[a] = l[a].conj().T @ g0 @ near(rng, 0.12) if not is_tree(a, mu) else I2\n vs0 = sites(g0, u, l, w)\n if max(delta(v) for v in vs0) > 0.25:\n continue\n tested += 1\n c, _ = average(g0, u, l, w)\n rho = 10 ** rng.uniform(-6, -3)\n def pert(x):\n return x @ near(rng, rho)\n u2 = {a: (I2 if is_tree(a, mu) else pert(u[a])) for a in OFFS}\n w2 = {a: (I2 if is_tree(a, mu) else pert(w[a])) for a in OFFS}\n l2 = {a: (pert(l[a]) if a != (0, 0, 0) else None) for a in OFFS}\n x = g0\n for it in range(300):\n l2[(0, 0, 0)] = x\n vs = sites(x, u2, l2, w2)\n worst_site = max(worst_site, max(delta(v) for v in vs))\n N = sum(lg(v) for v in vs) / 16\n x = c @ expm(-N)\n worst_ratio = max(worst_ratio, dist(x, g0) / rho)\n l2[(0, 0, 0)] = x\n V, vs = average(x, u2, l2, w2)\n conv &= np.linalg.norm(V - c) < 1e-10\n cols = []\n for k in range(3):\n e = 1e-7\n Vs = []\n for s in (e, -e):\n l3 = dict(l2); l3[(0, 0, 0)] = expm(s * B[k]) @ x\n Vs.append(average(l3[(0, 0, 0)], u2, l3, w2)[0])\n cols.append(coords(lg(Vs[0] @ V.conj().T) - lg(Vs[1] @ V.conj().T)) / (2 * e))\n max_det = max(max_det, abs(np.linalg.det(np.array(cols).T)))\nprint(f"regular backgrounds: {tested} tested, largest d(l, l_0)/rho {worst_ratio:.3f}, "\n f"largest site {worst_site:.3f}, largest |det| {max_det:.4f}")\ncheck("the iteration stays within 44 rho of the path link and solves the constraint",\n tested > 100 and conv and worst_ratio <= 44)\ncheck("the sites stay within 1/2 of I, so the cut-off equals 1", worst_site < 0.5)\ncheck(f"|det dV/dl_0| <= 1.957^3 = {1.957 ** 3:.3f}", max_det <= 1.957 ** 3)\ncheck(f"1/4 + 46/1076 < 1/2 and 7 Lambda/8 * 46 = {46 * K7:.3f} < 44", 0.25 + 46 / 1076 < 0.5 and 46 * K7 < 44)\nP = 4 * 269\ncheck(f"2.93 * 14 * 1076^3 = {2.93 * 14 * P ** 3:.3e} < 5.2e10", 2.93 * 14 * P ** 3 < 5.2e10)\ncheck("94 * 2 sqrt 2 + 47^2 * 1e-3 < 269", 94 * 2 * np.sqrt(2) + 47 ** 2 * 1e-3 < 269)\nprint(f"{sum(checks)} of {len(checks)} checks passed")\n', 'explicit_constants.py': '"""Checks of the explicit constants c_3 and c_6 of Theorem fibrechart\n(proposition explicitconstants).\n\n(A) evaluates the chain of bounds of the proof at the chosen radii and checks\n that m! S(R)/R^m <= 1.5e4 for m = 1, 2, 3 (operator norm), and the bound\n for the derivatives of log j;\n(B) adds up the constant c_6 / (dim G c_3^2) of the proof;\n(C) for SU(2), on random backgrounds whose sixteen sites lie within 1e-6 of I,\n computes the derivatives of order 1 to 3 of c(X) = log(V(U)^{-1} V(U e^X))\n by finite differences along random directions Y with N(Y) = 1 and checks\n that they are far below c_3.\nDouble precision; the proofs in the paper are by hand.\nUsage: python3 explicit_constants.py\n"""\nimport itertools\nimport math\nimport numpy as np\nfrom scipy.linalg import expm, logm\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append(bool(ok))\n print(("PASS " if ok else "FAIL ") + name)\n\n\n# (A) the chain of bounds, with a = 1e-6 and x0 = 1e-3 (rho_G <= 1)\nA0, X0 = 1e-6, 1e-3\nE0 = A0 + 3 * X0\nG0 = X0 + 3 * X0 / (1 - E0)\n\n\ndef S(t):\n phi = math.expm1(t)\n psi = (1 + phi) ** 3 - 1\n if E0 + psi >= 1:\n return None\n d = psi / (1 - E0 - psi)\n eta = (1 + phi) * math.exp(d) - 1\n if G0 + eta >= 1:\n return None\n return eta / (1 - G0 - eta)\n\n\nradii = {1: 1e-3, 2: 0.05, 3: 0.07}\nbounds = {m: math.factorial(m) * S(R) / R ** m for m, R in radii.items()}\nprint("gamma_0 = %.6f" % G0, {m: round(b, 1) for m, b in bounds.items()})\ncheck("m! S(R)/R^m <= 1.5e4 at R = 1e-3, 0.05, 0.07", max(bounds.values()) <= 1.5e4)\ns3 = math.sinh(1.5) / 1.5 - 1\nmg = -math.log(1 - s3)\nR = 0.8\nu = 2 * (X0 + R) / 3\nsupF = mg * u ** 2 / (1 - u ** 2)\nprint("sinh(1.5)/1.5 - 1 = %.5f, sup|g| <= %.5f, sup|log j| <= %.4f dim G" % (s3, mg, supF))\ncheck("first two derivatives of log j <= dim G", s3 <= 0.4196 and mg <= 0.5441\n and supF / R <= 1 and 2 * supF / R ** 2 <= 1)\n\n# (B) the constant c_6\nkb = 34 * 0.63\na, b = 2.1, 2.1 + 2 * 744 # ||A\'||_2^2 and ||A\'\'||_1 over dim G c_3^2 T\npi1, pi2 = kb + kb ** 2, (2 * kb ** 3 + 2 * kb ** 2, kb ** 2 + kb)\nT2 = 25 * b + 1275 * a\nT3 = 0.5 * ((pi2[0] * a + pi2[1] * b) / 3 + (2 + 1 / 9) * 481 ** 2 * a)\ntotal = 745 + T2 + T3\nprint("||Pi\'|| <= %.1f ||A\'||, ||Pi\'\'|| <= %.0f ||A\'||^2 + %.1f ||A\'\'||; c_6 <= %.0f dim G c_3^2"\n % (pi1, pi2[0], pi2[1], total))\ncheck("481 and 20576, 481 bound the derivatives of Pi", pi1 <= 481 and pi2[0] <= 20576 and pi2[1] <= 481)\ncheck("c_6 <= 6.81e5 dim G c_3^2", total <= 6.81e5)\n\n# SU(2) thresholds\nc3s = 1.5e4 * math.sqrt(2)\nc6s = 6.81e5 * 3 * c3s ** 2\nkmax = 6.0e-13 / (1 + 1.24e5)\nC0 = 0.5 + 2 / 3 * math.log(24 * math.pi ** 3)\nbq = 1.0\nwhile bq * kmax ** 2 <= 96 * (math.log(bq) + C0):\n bq *= 1.001\nlam_calm = 45 * math.log(3e8 * 384 ** 1.5 / kmax ** 3) / (0.75 * kmax ** 2)\nprint("SU(2): c_3 = %.0f, c_6 = %.3e, 60 c_6 = %.3e, kappa <= %.3e, q < 1 needs beta > %.2e, "\n "calm fibres need beta > %.2e |W|" % (c3s, c6s, 60 * c6s, kmax, bq, 4 * lam_calm))\ncheck("c_3 <= 2.13e4, c_6 <= 9.3e14, 60 c_6 < 5.6e16, 4 * 5.6e16 <= 2.3e17",\n c3s <= 2.13e4 and c6s <= 9.3e14 and 60 * c6s < 5.6e16)\ncheck("4e5 c_3 (kappa + s) <= 1/195 when kappa + s <= 6.0e-13, and then s <= 1/(6000 c_3), kappa + 6s <= 1e-8",\n 4e5 * c3s * 6.0e-13 <= 1 / 195 and 6.0e-13 <= 1 / (6000 * c3s) and 6 * 6.0e-13 <= 1e-8)\ncheck("kappa < 4.9e-18, beta_W > 3.8e38 for q < 1, 1.5e39 |W| for calm fibres",\n kmax < 4.9e-18 and 3.8e38 <= bq and 1.5e39 <= 4 * lam_calm)\n\n# (C) SU(2): numerical derivatives\nSg = [np.array(m, complex) for m in ([[0, 1], [-1, 0]], [[0, 1j], [1j, 0]], [[1j, 0], [0, -1j]])]\nB = [s / np.sqrt(2) for s in Sg]\nI2 = np.eye(2, dtype=complex)\n\n\ndef alg(c):\n return sum(ci * bb for ci, bb in zip(c, B))\n\n\ndef haar(rng):\n q = rng.normal(size=4); q /= np.linalg.norm(q)\n return np.array([[q[0] + 1j * q[1], q[2] + 1j * q[3]], [-q[2] + 1j * q[3], q[0] - 1j * q[1]]])\n\n\ndef lg(g):\n Xm = logm(g)\n return (Xm - Xm.conj().T) / 2\n\n\nOFFS = [o for o in itertools.product((0, 1), repeat=3) if o != (0, 0, 0)]\n\n\ndef V(links):\n g = links["g"]\n vs = [I2]\n for o in OFFS:\n vs += [g.conj().T @ links["u", o] @ links["l", o], g.conj().T @ links["l", o] @ links["w", o]]\n vs.append(I2) # the straight path, through a tree link\n return g @ expm(sum(lg(v) for v in vs) / 16)\n\n\nrng = np.random.default_rng(5)\nworst = [0.0, 0.0, 0.0]\nfor trial in range(40):\n g = haar(rng)\n L = {"g": g}\n for o in OFFS:\n L["u", o] = haar(rng)\n L["l", o] = L["u", o].conj().T @ g @ expm(alg(rng.normal(size=3)) * 1e-7)\n L["w", o] = L["l", o].conj().T @ g @ expm(alg(rng.normal(size=3)) * 1e-7)\n keys = list(L)\n X = {k: alg(rng.normal(size=3)) * 1e-3 / 3 for k in keys}\n Y = {k: alg(rng.normal(size=3)) for k in keys}\n nY = math.sqrt(sum(np.real(np.trace(y.conj().T @ y)) for y in Y.values()))\n Y = {k: y / nY for k, y in Y.items()}\n V0inv = V(L).conj().T\n\n def c(t):\n return lg(V0inv @ V({k: L[k] @ expm(X[k] + t * Y[k]) for k in keys}))\n\n h = 2e-2\n f = {j: c(j * h) for j in (-2, -1, 0, 1, 2)}\n d1 = (f[1] - f[-1]) / (2 * h)\n d2 = (f[1] - 2 * f[0] + f[-1]) / h ** 2\n d3 = (f[2] - 2 * f[1] + 2 * f[-1] - f[-2]) / (2 * h ** 3)\n for i, dd in enumerate((d1, d2, d3)):\n worst[i] = max(worst[i], np.linalg.norm(dd))\nprint("SU(2): largest |D^m c[Y,..,Y]| for m = 1, 2, 3: %.3f, %.3f, %.3f" % tuple(worst))\nc3 = 1.5e4 * math.sqrt(2)\ncheck("the derivatives are below c_3 = 1.5e4 sqrt 2 = %.0f" % c3, max(worst) < c3)\nprint(f"{sum(checks)} of {len(checks)} checks passed")\n', 'explicit_decay.py': '"""Checks of the weighted operator norms (lemma weightednorms) and of the\nexplicit rate and amplitude of the chart decay (proposition explicitdecay).\n\n(A) evaluates the chain of bounds of the proof at theta\' = 0.197,\n theta\'\' = 0.6 and alpha = 2.5e-4 and checks every number stated there;\n(B) on random Hermitian block matrices of finite range along a chain, checks\n |Re M^w - M| <= 2 (theta/theta\')^2 |M|_(theta\') with the weighted norm\n replaced by the largest value found over many Lipschitz weights, which\n is smaller than the true norm, so the test is stronger than the lemma;\n(C) checks Re (s^* s)^w >= -sigma^2 sinh^2(theta) on random rows s with\n weights that move by at most one;\n(D) checks, for random positive matrices of range two with Re M^w >= c,\n that the blocks of M^{-1} are at most e^{-theta d}/c.\nDouble precision; the proofs in the paper are by hand.\nUsage: python3 explicit_decay.py\n"""\nfrom math import cosh, sinh, exp, sqrt\nimport numpy as np\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append(bool(ok))\n print(("PASS " if ok else "FAIL ") + name)\n\n\n# (A) the chain of bounds\nkap = 1e-8\nc3s = 1 / (4e5 * 195)\nc3kp = 6 * c3s\nepsA = 7.35 * c3s\nRB = 2 + 24 * 260 * kap\nCB = 2 * (1 / 8 + 260 * kap)\nsig = (sqrt(11) / 8 + 260 * kap) / (1 / 8 - 260 * kap)\nLAM60 = 60 * 6.81e5\n\n\ndef norms(t):\n b = exp(t) * sqrt(RB * CB)\n amb = exp(t) * sqrt(48) * epsA\n a = b + amb\n gG = 1 / (1 / 16 - 700 * kap - (cosh(2 * t) - 1) * (1 / 16 + 454 * kap))\n E = amb * b\n h = gG / (1 - gG * E)\n g = gG / (1 - gG * (2 * E + amb ** 2))\n y = b * h\n sb = sqrt(1 + 2 * sig ** 2 * exp(2 * t))\n pb = sb * (1 + y * amb)\n return b, amb, a, gG, h, g, y, sb, pb\n\n\nt1, t2, alpha = 0.197, 0.6, 2.5e-4\nb, amb, a, gG, h, g, y, sb, pb = norms(t1)\nm = norms(t2)[6] * norms(t2)[1] * norms(t2)[7]\ng2 = 1 / (1 - 2 * sig ** 2 * sinh(t1) ** 2 - 2 * m ** 2 * (t1 / t2) ** 2)\nh1 = 17 / (1 - 17 * 2 * RB * epsA)\nx1 = 2 * RB * h1 * exp(2 * t1) * pb ** 2\naa = 2 * exp(2 * t1) * pb ** 2\nabar = 2 * (exp(2 * t1) * pb ** 2 + x1)\nk0 = (pb ** 2 + x1) + (g * a * abar + (g + 2 * g ** 2 * a ** 2) * exp(2 * t1) * aa) \\\n + (g2 * pb ** 2 * y * abar + (3 * g2 * pb ** 2 * y ** 2 + 2 * g2 ** 2 * pb ** 4 * y ** 2) * exp(2 * t1) * aa)\nk1 = 48 * exp(t1) * pb ** 2 + 12 * c3kp * x1\nK = k1 + k0 / LAM60\npa = norms(alpha)[8]\nprint(f"b {b:.4f} g0 {gG:.4f} h0 {h:.4f} g1 {g:.4f} y {y:.4f} s,p {sb:.4f} {pb:.4f} g2 {g2:.4f}")\nprint(f"sigma {sig:.4f} h1 {h1:.5f} k1 {k1:.1f} k0 {k0:.4e} K/lambda {K:.1f}")\nprint(f"alpha_max {t1 / sqrt(240 * K):.4e} pbar(alpha) {pa:.4f} c9 {480 * pa ** 2:.1f}")\ncheck("c_3 s <= 1.29e-8 and c_3 kappa\' <= 7.7e-8", c3s <= 1.29e-8 and c3kp <= 7.7e-8)\ncheck("b <= e^t (1/2 + 1e-4)^(1/2) and b <= 0.862", RB * CB <= 0.5 + 1e-4 and b <= 0.862)\ncheck("sigma <= 3.32", sig <= 3.32)\ncheck("g0, h0, g1 <= 17.37, y <= 14.96, s, p <= 5.80, g2 <= 7.41",\n max(gG, h, g) <= 17.37 and y <= 14.96 and max(sb, pb) <= 5.80 and g2 <= 7.41)\ncheck("h1 <= 17.001", h1 <= 17.001)\ncheck("k1 <= 1966, k0 <= 4.16e9, K <= 2068 lambda", k1 <= 1966 and k0 <= 4.16e9 and K <= 2068)\ncheck("2.5e-4 <= 0.197 (240 * 2068)^(-1/2)", alpha <= t1 / sqrt(240 * 2068))\ncheck("pbar(alpha) <= 4.8 and 480 * 4.8^2 <= 1.2e4", pa <= 4.8 and 480 * 4.8 ** 2 <= 1.2e4)\ncheck("60 c_6 = 4.086e7 dim G c_3^2", abs(LAM60 - 4.086e7) < 1e3)\n\nrng = np.random.default_rng(5)\nn, dblk = 40, 3\n\n\ndef lipschitz(rng, n):\n steps = rng.uniform(-1, 1, n - 1)\n return np.concatenate([[0], np.cumsum(steps)])\n\n\ndef conj(M, phi, t):\n w = np.repeat(np.exp(t * phi), dblk)\n return (w[:, None] * M) / w[None, :]\n\n\ndef banded(rng, R):\n M = np.zeros((n * dblk, n * dblk))\n for i in range(n):\n for j in range(max(0, i - R), min(n, i + R + 1)):\n M[i * dblk:(i + 1) * dblk, j * dblk:(j + 1) * dblk] = rng.normal(size=(dblk, dblk))\n return M\n\n\n# (B) the Hermitian part of a conjugate\nworst = 0.0\nfor trial in range(30):\n M = banded(rng, 2); M = (M + M.T) / 2\n tp = rng.uniform(0.1, 0.8)\n phis = [lipschitz(rng, n) for _ in range(60)] + [np.abs(np.arange(n) - k) for k in range(0, n, 5)]\n Kp = max(np.linalg.norm(conj(M, p, tp), 2) for p in phis)\n for p in phis[:20]:\n t = tp * rng.uniform(0, 1)\n Mw = conj(M, p, t)\n lhs = np.linalg.norm((Mw + Mw.T) / 2 - M, 2)\n worst = max(worst, lhs / (2 * (t / tp) ** 2 * Kp))\nprint(f"(B) largest ratio |Re M^w - M| / (2 (t/t\')^2 |M|_(t\')) {worst:.3f}")\ncheck("Schwarz bound for the Hermitian part of a conjugate", worst <= 1)\n\n# (C) one row of the section\nworst = 0.0\nfor trial in range(2000):\n k = 24\n s = rng.normal(size=(3, 3 * k))\n sg = np.linalg.norm(s, 2)\n t = rng.uniform(0, 1)\n D = np.repeat(np.exp(t * rng.uniform(-1, 1, k)), 3)\n u, v = s * D, s / D\n R = (v.T @ u + u.T @ v) / 2\n worst = max(worst, -np.linalg.eigvalsh(R).min() / (sg ** 2 * sinh(t) ** 2 + 1e-300))\nprint(f"(C) largest -min Re(s^*s)^w / (sigma^2 sinh^2 t) {worst:.3f}")\ncheck("Re (s^* s)^w >= -sigma^2 sinh^2 t", worst <= 1 + 1e-9)\n\n# (D) decay of inverses\nworst = 0.0\nfor trial in range(30):\n Bm = banded(rng, 1) * 0.15\n M = Bm @ Bm.T + 0.5 * np.eye(n * dblk)\n t = rng.uniform(0.05, 0.4)\n off = M.copy()\n for i in range(n):\n off[i * dblk:(i + 1) * dblk, i * dblk:(i + 1) * dblk] = 0\n rows = [sum(np.linalg.norm(off[i * dblk:(i + 1) * dblk, j * dblk:(j + 1) * dblk], 2) for j in range(n))\n for i in range(n)]\n c = np.linalg.eigvalsh(M).min() - (cosh(2 * t) - 1) * max(rows)\n if c <= 0:\n continue\n Mi = np.linalg.inv(M)\n for i in range(n):\n for j in range(n):\n blk = np.linalg.norm(Mi[i * dblk:(i + 1) * dblk, j * dblk:(j + 1) * dblk], 2)\n worst = max(worst, blk * exp(t * abs(i - j)) * c)\nprint(f"(D) largest |(M^-1)_ab| e^(t d) c {worst:.3f}")\ncheck("blocks of the inverse at most e^(-t d)/c", worst <= 1 + 1e-9)\nprint(f"{sum(checks)} of {len(checks)} checks passed")\n', 'fibre_chart.py': '"""Checks of the convex chart of the fibres of the cut-off average\n(Theorem thm:fibrechart of the forest paper, Sec. ssec:smallfibres), for\nG = SU(2) on the periodic lattice of side 4.\n\nThe backgrounds are those of small_field_fibre.py: block gauge transforms of\nfields whose plaquettes have angle of order eps. For a set W of blocks, T is\nthe tangent space of the fibre F at U, and the chart is\nPhi(eta) = U exp(eta + h(eta)), eta in T, h(eta) in the orthogonal complement\nN = range DC^*, found by the iteration z -> z - G^{-1} C(eta + DC^* z) of the\nproof. The program\n\n (f) solves for h at random points eta of the l^infinity ball K_s of T and\n checks that Phi(eta) lies on F, that h(eta) is orthogonal to T, that\n the iteration contracts, and records |h(eta)|_inf / |eta|_inf^2;\n (g) computes, by second differences, the Hessian of Q o Phi at such points\n in the direction of least Q_U on T and in random directions of T, and\n checks that it is at least 1/26;\n (h) computes the Hessian of psi = -sum_e log det Psi(ad X_e)\n + 1/2 log det(A_X A_X^*) - 1/2 log det(1 + Dh^* Dh), the logarithm of\n the Haar, coarea and area factors of the theorem, and records\n |psi\'\'(zeta, zeta)| / |zeta|^2, which the theorem bounds by a constant\n c_6 that does not depend on lambda, W or the lattice;\n (j) checks the arithmetic of the constants of the proof exactly.\n\nThese are floating-point checks at fields far larger than those of the\ntheorem; they are not interval certificates.\n\nUsage: python3 fibre_chart.py\n"""\n\nfrom fractions import Fraction as Fr\n\nimport numpy as np\n\nimport small_field_fibre as S\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append((name, bool(ok)))\n print(("PASS " if ok else "FAIL ") + name)\n\n\ndef setup(eps, W, seed):\n rng = np.random.default_rng(seed)\n U = S.make_field(eps, rng)\n kappa = max(S.dist(S.hol(U, p), S.I2) for p in S.PLAQ)\n Wset = set(W)\n var = [(x, mu) for x in S.SITES for mu in range(S.DIM)\n if not S.is_tree(x, mu) and S.blk(x) in Wset]\n vid = {l: i for i, l in enumerate(var)}\n cons = [(y, mu) for y in W for mu in range(S.DIM)]\n V0 = {k: S.vsharp(U, *k)[0] for k in cons}\n plist = [p for p in S.PLAQ if any(l in vid for l in S.plinks(p))]\n return dict(U=U, kappa=kappa, var=var, vid=vid, cons=cons, V0=V0,\n plist=plist, n=3 * len(var), rng=rng)\n\n\ndef moved(st, X):\n Uf = dict(st["U"])\n for l, i in st["vid"].items():\n Uf[l] = st["U"][l] @ S.expm(X[3 * i:3 * i + 3])\n return Uf\n\n\ndef Cval(st, X):\n Uf = moved(st, X)\n return np.concatenate([S.logm(st["V0"][k].conj().T @ S.vsharp(Uf, *k)[0])\n for k in st["cons"]])\n\n\ndef Qval(st, X):\n Uf = moved(st, X)\n return sum(S.dist(S.hol(Uf, p), S.I2) ** 2 for p in st["plist"])\n\n\ndef jac(st, X, t=1e-5):\n """A_X = derivative of X -> C(U e^X), by central differences on the 24\n links of each constraint."""\n vid, cons = st["vid"], st["cons"]\n A = np.zeros((3 * len(cons), st["n"]))\n Uf = moved(st, X)\n for k, (y, mu) in enumerate(cons):\n Vk = st["V0"][(y, mu)]\n for l in S.vlinks(y, mu):\n if l not in vid:\n continue\n i = vid[l]\n base = Uf[l]\n for c in range(3):\n d = np.zeros(3)\n d[c] = t\n Uf[l] = st["U"][l] @ S.expm(X[3 * i:3 * i + 3] + d)\n Vp = S.vsharp(Uf, y, mu)[0]\n Uf[l] = st["U"][l] @ S.expm(X[3 * i:3 * i + 3] - d)\n Vm = S.vsharp(Uf, y, mu)[0]\n Uf[l] = base\n A[3 * k:3 * k + 3, 3 * i + c] = (S.logm(Vk.conj().T @ Vp) - S.logm(Vk.conj().T @ Vm)) / (2 * t)\n return A\n\n\ndef solve_h(st, eta, B, Ginv, iters=12):\n z = np.zeros(B.shape[0])\n steps = []\n for _ in range(iters):\n znew = z - Ginv @ Cval(st, eta + B.T @ z)\n steps.append(np.max(np.abs(znew - z)))\n z = znew\n if steps[-1] < 1e-14:\n break\n return B.T @ z, steps\n\n\ndef linf(X):\n return np.max(np.linalg.norm(X.reshape(-1, 3), axis=1))\n\n\ndef logdetPsi(c):\n """log det Psi(ad X) for X in su(2) with coordinates c (HS norm): the\n eigenvalues of ad X are 0 and +-i sqrt(2)|c|."""\n th = np.sqrt(2) * np.linalg.norm(c)\n if th < 1e-12:\n return 0.0\n # Psi(z) = (1 - e^{-z})/z at z = +-i th: |Psi|^2 = (2 - 2 cos th)/th^2\n return np.log((2 - 2 * np.cos(th)) / th ** 2)\n\n\ndef run(eps, W, seed, s, label):\n st = setup(eps, W, seed)\n rng = st["rng"]\n kappa = st["kappa"]\n tag = f"eps={eps:g}, |W|={len(W)}, kappa={kappa:.3e}, s={s:g}"\n print(f"-- {label}: {tag}")\n n = st["n"]\n B = jac(st, np.zeros(n))\n G = B @ B.T\n Ginv = np.linalg.inv(G)\n _, sv, Vt = np.linalg.svd(B)\n rank = int(np.sum(sv > 1e-8))\n Nb = Vt[rank:].T # orthonormal basis of T\n\n # the covariant curvature form at U, for the least direction\n D = np.zeros((3 * len(st["plist"]), n))\n for r, p in enumerate(st["plist"]):\n A4 = S.dmaps(st["U"], p)\n for i, l in enumerate(S.plinks(p)):\n if l in st["vid"]:\n D[3 * r:3 * r + 3, 3 * st["vid"][l]:3 * st["vid"][l] + 3] += A4[i]\n QU = D.T @ D\n least = Nb @ np.linalg.eigh(Nb.T @ QU @ Nb)[1][:, 0]\n\n def sample_eta(frac):\n v = Nb @ rng.normal(size=Nb.shape[1])\n return frac * s * v / linf(v)\n\n def chart(eta):\n h, steps = solve_h(st, eta, B, Ginv)\n return eta + h, h, steps\n\n # (f) chart\n ok_on, ok_orth, ok_contr = True, True, True\n ratios = []\n pts = [sample_eta(f) for f in (0.5, 1.0, 1.0)]\n for eta in pts:\n X, h, steps = chart(eta)\n ok_on &= np.max(np.abs(Cval(st, X))) <= 1e-11\n ok_orth &= np.max(np.abs(Nb.T @ h)) <= 1e-12\n ok_contr &= all(steps[i + 1] <= 0.5 * steps[i] + 1e-15 for i in range(len(steps) - 1))\n ratios.append(linf(h) / linf(eta) ** 2)\n check(f"(f) Phi(eta) lies on F (|C| <= 1e-11) at three points of K_s ({tag})", ok_on)\n check(f"(f) h(eta) is orthogonal to T ({tag})", ok_orth)\n check(f"(f) the iteration for h contracts by at least 1/2 per step ({tag})", ok_contr)\n check(f"(f) |h|_inf/|eta|_inf^2 = {max(ratios):.3f} stays bounded (<= 50) ({tag})", max(ratios) <= 50)\n pk = max(S.dist(S.hol(moved(st, chart(eta)[0]), p), S.I2) for eta in pts[1:] for p in st["plist"])\n check(f"(f) plaquettes on Phi(K_s) at most kappa + 6 s ({pk:.4f} <= {kappa + 6 * s:.4f})",\n pk <= kappa + 6 * s)\n\n # (g) and (h): second differences along eta + t zeta\n def QPhi(eta):\n return Qval(st, chart(eta)[0])\n\n def psi(eta):\n X, _, _ = chart(eta)\n A = jac(st, X)\n haar = -sum(logdetPsi(X[3 * i:3 * i + 3]) for i in range(len(st["var"])))\n cor = 0.5 * np.linalg.slogdet(A @ A.T)[1]\n # Dh on T: -B^*(A B^*)^{-1} A\n Sm = -B.T @ np.linalg.solve(A @ B.T, A @ Nb)\n area = -0.5 * np.linalg.slogdet(np.eye(Nb.shape[1]) + Sm.T @ Sm)[1]\n return haar + cor + area, np.linalg.norm(Sm, 2)\n\n hq, hp, snorm = [], [], []\n base = pts[1]\n dirs = [least] + [Nb @ rng.normal(size=Nb.shape[1]) for _ in range(2)]\n for zeta in dirs:\n zeta = zeta / np.linalg.norm(zeta)\n t = 2e-3\n q0, qp, qm = QPhi(base), QPhi(base + t * zeta), QPhi(base - t * zeta)\n hq.append((qp - 2 * q0 + qm) / t ** 2)\n t2 = 3e-2\n p0, sn = psi(base)\n pp, _ = psi(base + t2 * zeta)\n pm, _ = psi(base - t2 * zeta)\n hp.append(abs(pp - 2 * p0 + pm) / t2 ** 2)\n snorm.append(sn)\n check(f"(g) Hessian of Q o Phi at a point of K_s, least and two random directions: "\n f"{\', \'.join(f\'{v:.5f}\' for v in hq)} (all >= 1/26) ({tag})", min(hq) >= 1 / 26)\n check(f"(h) |psi\'\'(zeta,zeta)|/|zeta|^2 = {\', \'.join(f\'{v:.3f}\' for v in hp)} (<= 10) ({tag})",\n max(hp) <= 10)\n check(f"(h) |Dh| = {max(snorm):.4f} <= 1/6 on K_s ({tag})", max(snorm) <= 1 / 6)\n return max(hp)\n\n\ndef constants():\n c3 = 1 # every bound below is used with c_3 >= 1 and s <= 1/(6000 c_3)\n check("constants: 17*12*4 = 816 and 0.88*816 <= 720", 17 * 12 * 4 == 816 and Fr(88, 100) * 816 <= 720)\n check("constants: 17*48*0.88 <= 720 and 720/1440 = 1/2, 816/6000 <= 1",\n 17 * 48 * Fr(88, 100) <= 720 and Fr(720, 1440) == Fr(1, 2) and Fr(816, 6000) <= 1)\n check("constants: 720 s^2 <= s/2 for s <= 1/1440", Fr(720, 1440) <= Fr(1, 2))\n check("constants: 2*0.44 = 0.88, 0.44*sqrt(24) <= 2.2, 0.88*17*2.2 <= 33, 17*2.2 <= 38, 34/40 < 1",\n 2 * 0.44 == 0.88 and 0.44 * np.sqrt(24) <= 2.2 and 0.88 * 17 * 2.2 <= 33 and 17 * 2.2 <= 38)\n check("constants: sqrt(24)*1.5 <= 7.4, 7.4*sqrt(2) <= 10.5, 0.44*sqrt(2) <= 0.63",\n np.sqrt(24) * 1.5 <= 7.4 and 7.4 * np.sqrt(2) <= 10.5 and 0.44 * np.sqrt(2) <= 0.63)\n s = Fr(1, 6000)\n check("constants: 17*10.5*0.63 s <= 1/2 and 0.63*34*10.5 s <= 1/6 at s = 1/6000",\n 17 * Fr(105, 10) * Fr(63, 100) * s <= Fr(1, 2) and Fr(63, 100) * 34 * Fr(105, 10) * s <= Fr(1, 6))\n check("constants: 24*0.44 <= 10.6, 2*7.4 = 14.8, 14.8*10.6 <= 157, 17*157 s <= 1/2",\n 24 * Fr(44, 100) <= Fr(106, 10) and Fr(148, 10) * Fr(106, 10) <= 157 and 17 * 157 * s <= Fr(1, 2))\n check("constants: 1 + 1/36 <= 1.03 and 10.6*34*2*1.03 <= 744",\n 1 + Fr(1, 36) <= Fr(103, 100) and Fr(106, 10) * 34 * 2 * Fr(103, 100) <= 744)\n check("constants: 3s*1.03 + (1 + 3s)*744 <= 750 at s = 1/6000",\n 3 * s * Fr(103, 100) + (1 + 3 * s) * 744 <= 750)\n check("constants: 12*750 = 9000 and 6(5.4e4 + 9000 c3) + 1 <= 4e5 c3 for c3 >= 1",\n 12 * 750 == 9000 and all(6 * (54000 + 9000 * c) + 1 <= 400000 * c for c in (1, 2, 10, 10 ** 6)))\n check("constants: (1 - 6s)/26 >= 1/26 - s/4", Fr(1, 26) * (1 - 6 * s) >= Fr(1, 26) - s / 4)\n check("constants: 1/sqrt(17) - 10.5 s >= 0.2, so |M^{-1}| <= 25",\n 1 / np.sqrt(17) - 10.5 / 6000 >= 0.2)\n check("constants: 1/26 - 1/195 = 1/30 and 1/30 - 1/60 = 1/60",\n Fr(1, 26) - Fr(1, 195) == Fr(1, 30) and Fr(1, 30) - Fr(1, 60) == Fr(1, 60))\n check("constants: 0.63*34*(1 + 0.63*34) <= 481", Fr(63, 100) * 34 * (1 + Fr(63, 100) * 34) <= 481)\n\n\nif __name__ == "__main__":\n constants()\n blocks = S.BLOCKS\n two = [blocks[0], blocks[1]]\n eight = [y for y in blocks if sum(y) % 2 == 0]\n c6 = []\n for eps, W, seed, s, lab in ((1e-3, two, 5, 1e-2, "two blocks"),\n (1e-3, eight, 6, 1e-2, "eight blocks"),\n (1e-2, eight, 7, 3e-2, "eight blocks"),\n (1e-3, blocks, 8, 1e-2, "sixteen blocks")):\n c6.append(run(eps, W, seed, s, lab))\n print(f"largest |psi\'\'|/|zeta|^2 observed: {max(c6):.3f}")\n n_ok = sum(ok for _, ok in checks)\n print(f"{n_ok} of {len(checks)} checks passed")\n', 'fibre_compare.py': '"""Checks of the comparison of fibres through the law of the averages\n(proposition fibrecompare) and of its corollary on exteriors with a calm\ncompletion (corollary calmexterior).\n\n(A) checks every constant of the two proofs in exact rational arithmetic:\n n_P >= 74, rho < 1.5e-4, the bound 16 sqrt2 rho + 16 rho^2 < 22.63 rho,\n 22.63 n_P rho < t/4, 14 * 90.6^3 < 1.05e7, the arithmetic of the\n corollary, and, in double precision, the sufficient condition on beta_W\n for |W| up to 10^6;\n(B) on random SU(2) links checks delta <= d, delta <= 2 sqrt 2, the growth\n of delta(U_p, I)^2 when the four links of a plaquette move by at most\n rho, and the Haar mass of the ball of radius rho against rho^3/14;\nDouble precision in (B); the proofs in the paper are by hand.\nUsage: python3 fibre_compare.py\n"""\nfrom fractions import Fraction as Fr\nfrom math import sqrt, sin, cos, pi, log, exp\nimport numpy as np\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append(bool(ok))\n print(("PASS " if ok else "FAIL ") + name)\n\n\n# (A) constants\nnP_min = Fr(49 * 6, 4)\ncheck("n_P >= 74 (49 links, six plaquettes each, four per plaquette)",\n nP_min > 73)\nrho_max = Fr(1) / (Fr(906, 10) * 74)\ncheck("rho = t/(90.6 n_P) < 1.5e-4", rho_max < Fr(15, 100000))\n# 16 sqrt2 < 22.6275, and 16 rho^2 <= 16 * 1.5e-4 rho\ncheck("16 sqrt2 < 22.6275", Fr(226275, 10000) ** 2 > 512)\ncheck("16 sqrt2 + 16 * 1.5e-4 < 22.63",\n Fr(226275, 10000) + 16 * Fr(15, 100000) < Fr(2263, 100))\ncheck("22.63 / 90.6 < 1/4", Fr(2263, 100) / Fr(906, 10) < Fr(1, 4))\ncheck("14 * 90.6^3 < 1.05e7", 14 * Fr(906, 10) ** 3 < Fr(105, 10) * 10**6)\n# corollary: Q_* <= kappa^2/4, Q_W <= Q_* + kappa^2/2 = 3/4 kappa^2 < kappa^2\ncheck("kappa^2/4 + kappa^2/2 < kappa^2", Fr(1, 4) + Fr(1, 2) < 1)\ncheck("8.4e7 = 1.05e7 * 8", Fr(105, 10) * 10**6 * 8 == 84 * 10**6)\n# lambda kappa^2 >= 196 |W| L => (3/8) lam k^2 - 49|W| L >= lam k^2 / 8\ncheck("3/8 - 49/196 = 1/8", Fr(3, 8) - Fr(49, 196) == Fr(1, 8))\nK = 4.8e-18\nworst = 0.0\nfor W in [1, 2, 3, 5, 10, 30, 100, 10**3, 10**4, 10**5, 10**6]:\n nP = 384 * W\n k2 = K**2 / (16 * nP)\n L = log(8.4e7 * nP**3 / k2**3)\n beta = 256 * 49 * nP * W * L / K**2\n worst = max(worst, beta / (W**2 * (1 + log(W))))\ncheck(f"beta_W >= 6.4e43 |W|^2 (1+ln|W|) suffices (worst ratio {worst:.3e})",\n worst < 6.4e43)\ncheck("K = 4.8e-18 < 4.9e-18 and kappa <= K/4 <= 1e-8",\n K < 4.9e-18 and K / 4 <= 1e-8)\n\n# (B) SU(2)\nrng = np.random.default_rng(27)\n\n\ndef su2(q):\n a, b, c, d = q / np.linalg.norm(q)\n return np.array([[a + 1j * b, c + 1j * d], [-c + 1j * d, a - 1j * b]])\n\n\ndef haar():\n return su2(rng.normal(size=4))\n\n\ndef expm(X):\n # X in su(2): X = i (x . sigma), exp via closed form\n w, V = np.linalg.eig(X)\n return V @ np.diag(np.exp(w)) @ np.linalg.inv(V)\n\n\ndef delta(A, B):\n return np.linalg.norm(A - B)\n\n\ndef dist(A, B):\n w = np.linalg.eigvals(A.conj().T @ B)\n th = np.abs(np.angle(w))\n return sqrt(float(np.sum(th**2)))\n\n\ndef small(r):\n v = rng.normal(size=3)\n v *= r * rng.random() / (np.linalg.norm(v) * sqrt(2))\n X = 1j * (v[0] * np.array([[0, 1], [1, 0]]) +\n v[1] * np.array([[0, -1j], [1j, 0]]) +\n v[2] * np.array([[1, 0], [0, -1]]))\n return expm(X)\n\n\nI2 = np.eye(2)\nok1 = ok2 = True\nfor _ in range(20000):\n A, B = haar(), haar()\n ok1 &= delta(A, B) <= dist(A, B) + 1e-12\n ok2 &= delta(A, I2) <= 2 * sqrt(2) + 1e-12\ncheck("delta <= d on 20000 random pairs", ok1)\ncheck("delta(U, I) <= 2 sqrt2", ok2)\nworst = 0.0\nfor _ in range(20000):\n rho = 1.5e-4 * rng.random()\n U = [haar() for _ in range(4)]\n V = [u @ small(rho) for u in U]\n for u, v in zip(U, V):\n assert dist(u, v) <= rho * (1 + 1e-9)\n P = U[0] @ U[1] @ U[2].conj().T @ U[3].conj().T\n Pp = V[0] @ V[1] @ V[2].conj().T @ V[3].conj().T\n worst = max(worst, (delta(Pp, I2)**2 - delta(P, I2)**2) / rho)\ncheck(f"delta(U\'_p,I)^2 - delta(U_p,I)^2 < 22.63 rho (worst {worst:.3f})",\n worst < 22.63)\nokb = True\nfor rho in np.linspace(1e-6, 1.5e-4, 200):\n th = rho / sqrt(2)\n okb &= (2 * th - sin(2 * th)) / (2 * pi) >= rho**3 / 14\ncheck("h(B_rho) >= rho^3/14 for rho <= 1.5e-4", okb)\n\nprint(f"{sum(checks)} of {len(checks)} checks passed")\n', 'gauss_every_gauge.py': '"""Checks for prop:gaussevery: in the quadratic approximation the cube\ncondition D(n, alpha), alpha < 1, fails for every 2Z^4-invariant gauge given\nby a forest F of links whose trees are infinite and cover the sites.\n\nFor the direction field of Table tab:sigma and for the axial field sigma = 0:\n(A) the 2Z^4-periodic flat fields form a space of dimension 19, and those\n vanishing on F a space of dimension at least 3;\n(B) for n = 2, 4 the cube law is nondegenerate, its mean given the exterior\n of a flat field psi vanishing on F is psi itself, and the class sums obey\n sum_c a_c K_c >= N_n sum_c a_c with a_c = |psi| on the class c.\n"""\nimport itertools, sys\nimport numpy as np\n\nTAB = """0000 0\n1000 0\n0100 2\n1100 3\n0010 3\n1010 1\n0110 2\n1110 1\n0001 1\n1001 2\n0101 1\n1101 3\n0011 3\n1011 2\n0111 0\n1111 0"""\nSIGMA_TABLE = {tuple(int(ch) for ch in r.split()[0]): int(r.split()[1]) for r in TAB.splitlines()}\nE = [tuple(1 if i == m else 0 for i in range(4)) for m in range(4)]\nadd = lambda x, y: tuple(a + b for a, b in zip(x, y))\nmod2 = lambda x: tuple(a % 2 for a in x)\n\npassed = failed = 0\ndef check(name, ok):\n global passed, failed\n print(("PASS " if ok else "FAIL ") + name)\n if ok: passed += 1\n else: failed += 1\n\ndef plaquettes_at(x):\n for m in range(4):\n for v in range(m + 1, 4):\n # links with signs: (x,m)+, (x+e_m,v)+, (x+e_v,m)-, (x,v)-\n yield [((x, m), 1), ((add(x, E[m]), v), 1), ((add(x, E[v]), m), -1), ((x, v), -1)]\n\ndef run(label, sigma):\n inF = lambda l: sigma(mod2(l[0])) == l[1]\n # (A) periodic flat fields on the 2-torus cell: psi(x,mu) = c_mu + h(x+e_mu) - h(x)\n sites = list(itertools.product(range(2), repeat=4))\n links = [(x, m) for x in sites for m in range(4)]\n idx = {s: i for i, s in enumerate(sites)}\n M = np.zeros((64, 20))\n for r, (x, m) in enumerate(links):\n M[r, 16 + m] += 1\n M[r, idx[mod2(add(x, E[m]))]] += 1\n M[r, idx[x]] -= 1\n check(f"{label}: periodic flat fields have dimension 19", np.linalg.matrix_rank(M) == 19)\n Frows = [r for r, l in enumerate(links) if inF(l)]\n check(f"{label}: F has 16 classes", len(Frows) == 16)\n # flat fields vanishing on F: kernel of M[Frows] restricted to the image of M\n _, sv, Vt = np.linalg.svd(M[Frows])\n null = Vt[np.sum(sv > 1e-9):]\n sols = M @ null.T\n dim = np.linalg.matrix_rank(sols)\n check(f"{label}: flat periodic fields vanishing on F have dimension {dim} >= 3", dim >= 3)\n rng = np.random.default_rng(1)\n psi_cell = sols @ rng.standard_normal(sols.shape[1])\n psi_cell[np.abs(psi_cell) < 1e-12] = 0.0\n psi = lambda l: psi_cell[links.index((mod2(l[0]), l[1]))]\n # flatness on a sample of plaquettes\n flat = max(abs(sum(s * psi(l) for l, s in p)) for x in sites for p in plaquettes_at(x))\n check(f"{label}: psi is flat and vanishes on F", flat < 1e-10 and all(abs(psi_cell[r]) < 1e-12 for r in Frows))\n for n in (2, 4):\n V = [(x, m) for x in itertools.product(range(n), repeat=4) for m in range(4) if not inF((x, m))]\n vid = {l: i for i, l in enumerate(V)}\n Vset = set(V)\n # plaquettes meeting V: base points in [-1, n]^4\n P = []\n for x in itertools.product(range(-1, n + 1), repeat=4):\n for p in plaquettes_at(x):\n if any(l in Vset for l, _ in p):\n P.append(p)\n ext = sorted({l for p in P for l, _ in p if l not in Vset and not inF(l)})\n eid = {l: i for i, l in enumerate(ext)}\n Av = np.zeros((len(P), len(V))); Ae = np.zeros((len(P), len(ext)))\n for r, p in enumerate(P):\n for l, s in p:\n if l in vid: Av[r, vid[l]] += s\n elif l in eid: Ae[r, eid[l]] += s\n H = Av.T @ Av\n lam = np.linalg.eigvalsh(H)[0]\n check(f"{label}, n={n}: cube form nondegenerate (least eigenvalue {lam:.4f})", lam > 1e-6)\n U = -np.linalg.solve(H, Av.T @ Ae) # columns u_j\n pe = np.array([psi(l) for l in ext]); pv = np.array([psi(l) for l in V])\n check(f"{label}, n={n}: mean given psi outside equals psi", np.max(np.abs(U @ pe - pv)) < 1e-9)\n Cj = np.abs(U).sum(axis=0) # C_{V,j} = ||u_j||_1\n K = {}\n for l, c in zip(ext, Cj):\n key = (mod2(l[0]), l[1]); K[key] = K.get(key, 0.0) + c\n Nn = (n // 2) ** 4\n lhs = sum(abs(psi((k[0], k[1]))) * K.get(k, 0.0) for k in K)\n tot = sum(abs(psi(l)) for l in links if not inF(l))\n check(f"{label}, n={n}: sum_c a_c K_c = {lhs:.4f} >= N_n sum_c a_c = {Nn * tot:.4f}", lhs >= Nn * tot - 1e-9)\n cls = [(x, m) for x in sites for m in range(4) if not inF((x, m))]\n kmax = max(K.get(k, 0.0) for k in cls if abs(psi(k)) > 1e-12)\n check(f"{label}, n={n}: max_c K_c / N_n = {kmax / Nn:.4f} >= 1", kmax >= Nn - 1e-9)\n\nrun("forest gauge", lambda r: SIGMA_TABLE[r])\nrun("axial gauge", lambda r: 0)\nprint(f"{passed} checks passed, {failed} failed")\nsys.exit(1 if failed else 0)\n', 'gaussian_forest.py': '"""Weak-coupling (Gaussian) approximation of the forest gauge: exact cube coefficients.\n\nLinearise U = exp(i A) with A = 0 on the fixed links F; the action becomes\nbeta sum_p (dA)_p^2, and beta drops out of the response. For a Gaussian the\nconditional law of the cube V is a translate whose mean depends linearly on the\nboundary links, so the coefficient C_{V,j} of the paper is the l1 norm of the\nresponse column, exactly and for every exterior:\n K_c = sum_{j in c, j not in V} sum_{e in V} |(Q_VV^{-1} Q_Vj)_e|.\nPrints max, mean and min of K_c / N_n over the 48 classes. Needs scipy.\nRun: python3 gaussian_forest.py 2 4 6 8\nNothing in the paper rests on it."""\nimport itertools, sys, numpy as np, scipy.sparse as sp, scipy.sparse.linalg as spl\nfrom influence_mc import SIGMA\ndef sig(x): return SIGMA[tuple(v % 2 for v in x)]\ndef run(n, off=2):\n V = {}\n for x in itertools.product(range(off, off + n), repeat=4):\n for mu in range(4):\n if sig(x) != mu: V[(x, mu)] = len(V)\n E = lambda x, m: tuple(v + (1 if k == m else 0) for k, v in enumerate(x))\n rows = [] # plaquettes meeting V: list of (link, sign)\n seen = set()\n for (x, mu) in V:\n for nu in range(4):\n if nu == mu: continue\n for base in (x, tuple(v - (1 if k == nu else 0) for k, v in enumerate(x))):\n a, b = min(mu, nu), max(mu, nu)\n key = (base, a, b)\n if key in seen: continue\n seen.add(key)\n links = [((base, a), 1), ((E(base, a), b), 1), ((E(base, b), a), -1), ((base, b), -1)]\n rows.append([(l, s) for l, s in links if sig(l[0]) != l[1]]) # F links are fixed to 0\n B = {}\n for r in rows:\n for l, s in r:\n if l not in V and l not in B: B[l] = len(B)\n Qvv = sp.lil_matrix((len(V), len(V))); Qvb = sp.lil_matrix((len(V), len(B)))\n for r in rows:\n for l1, s1 in r:\n if l1 not in V: continue\n for l2, s2 in r:\n if l2 in V: Qvv[V[l1], V[l2]] += s1 * s2\n else: Qvb[V[l1], B[l2]] += s1 * s2\n lu = spl.splu(sp.csc_matrix(Qvv))\n Qvb = sp.csc_matrix(Qvb); C = np.zeros(len(B))\n for s0 in range(0, len(B), 800): # response of the cube means to each boundary link\n M = lu.solve(Qvb[:, s0:s0 + 800].toarray())\n C[s0:s0 + 800] = np.abs(M).sum(0)\n K = {}\n for (x, mu), i in B.items():\n c = (tuple(v % 2 for v in x), mu)\n K[c] = K.get(c, 0) + C[i]\n Nn = (n // 2) ** 4\n k = np.array(list(K.values())) / Nn\n print(f"n={n} |V|={len(V)} boundary={len(B)} classes={len(K)} K_c/N_n: max {k.max():.4f} mean {k.mean():.4f} min {k.min():.4f}", flush=True)\nfor n in map(int, sys.argv[1:]): run(n)\n', 'influence_mc.py': '"""Monte Carlo probe of the cube condition D(n, alpha) for SU(2) in the forest gauge.\n\nThe coefficient C_{V,j} of the paper is a supremum over all exteriors; no\nsimulation can bound it. This script estimates the same quantity for typical\nexteriors: an exterior is drawn by heat-bath sampling of the gauge-fixed\nmeasure in a box with trivial outer boundary, the link j next to the cube is\nrotated, and two heat-bath chains on the cube, one for each exterior, are run\nwith common random numbers. The time average of d_V between the two chains is\nan upper bound for the Kantorovich distance of the two cube measures (up to\nMonte Carlo error), so the ratio to delta(Q_j, Q\'_j) estimates the influence\nof j from above for that exterior. Summing over the links of a class gives an\nestimate of K_c / N_n, the quantity that D(n, alpha) bounds by alpha.\n\nRun: python3 influence_mc.py --beta 2.0 --n 4 [--samples 64 --sweeps 600]\nPrints one line per run; nothing in the paper rests on it.\n"""\nimport argparse\nimport math\nimport numpy as np\n\nTABLE = """0000 0\n1000 0\n0100 2\n1100 3\n0010 3\n1010 1\n0110 2\n1110 1\n0001 1\n1001 2\n0101 1\n1101 3\n0011 3\n1011 2\n0111 0\n1111 0"""\nSIGMA = np.zeros((2, 2, 2, 2), int) # residue modulo two -> direction of the line\nfor _row in TABLE.splitlines():\n _r, _s = _row.split()\n SIGMA[tuple(int(c) for c in _r)] = int(_s)\n\n# ---------------------------------------------------------------- quaternions\ndef qmul(a, b):\n a0, a1, a2, a3 = a[..., 0], a[..., 1], a[..., 2], a[..., 3]\n b0, b1, b2, b3 = b[..., 0], b[..., 1], b[..., 2], b[..., 3]\n return np.stack([a0 * b0 - a1 * b1 - a2 * b2 - a3 * b3,\n a0 * b1 + a1 * b0 + a2 * b3 - a3 * b2,\n a0 * b2 - a1 * b3 + a2 * b0 + a3 * b1,\n a0 * b3 + a1 * b2 - a2 * b1 + a3 * b0], axis=-1)\n\ndef qconj(a):\n return a * np.array([1.0, -1.0, -1.0, -1.0])\n\n# --------------------------------------------------------------------- lattice\nclass Box:\n """Links U[..., mu, x0, x1, x2, x3, :] on a box of side L (leading batch axis).\n\n Links with base point on the outer layer (index 0 or L-1) are the\n identity and never updated; links of the forest F are the identity.\n """\n\n def __init__(self, L, batch, rng):\n self.L, self.B, self.rng = L, batch, rng\n self.U = np.zeros((batch, 4, L, L, L, L, 4))\n self.U[..., 0] = 1.0\n idx = np.indices((L, L, L, L))\n res = idx % 2\n sig = SIGMA[res[0], res[1], res[2], res[3]]\n inner = np.ones((L,) * 4, bool)\n for d in range(4):\n inner &= (idx[d] >= 1) & (idx[d] <= L - 2)\n self.active = np.stack([(sig != mu) & inner for mu in range(4)])\n par = idx.sum(0) % 2\n self.colour = [[self.active[mu] & (par == p) for p in (0, 1)]\n for mu in range(4)]\n\n def staple(self, mu):\n U, S = self.U, np.zeros_like(self.U[:, 0])\n sh = lambda a, d, s: np.roll(a, -s, axis=1 + d) # a(x + s e_d)\n for nu in range(4):\n if nu == mu:\n continue\n Umu, Unu = U[:, mu], U[:, nu]\n fwd = qmul(qmul(sh(Unu, mu, 1), qconj(sh(Umu, nu, 1))), qconj(Unu))\n Unu_m = sh(Unu, nu, -1)\n bwd = qmul(qmul(qconj(sh(Unu_m, mu, 1)), qconj(sh(Umu, nu, -1))), Unu_m)\n S += fwd + bwd\n return S\n\n def heatbath(self, beta, rng, group=1, mask_extra=None):\n """One sweep. Rows of the batch are grouped in consecutive blocks of\n size `group`; rows of one block share their random numbers, which\n couples them (the chains of a pair). mask_extra restricts the update."""\n for mu in range(4):\n for p in (0, 1):\n m = self.colour[mu][p]\n if mask_extra is not None:\n m = m & mask_extra[mu]\n if not m.any():\n continue\n S = self.staple(mu)[:, m] # (B, k, 4)\n k = np.linalg.norm(S, axis=-1)\n # density of the new link u: exp(beta )\n mdir = qconj(S / k[..., None])\n self.U[:, mu][:, m] = sample_coupled(beta * k, mdir, group, rng)\n\ndef kp_x0(c, rng):\n """Kennedy-Pendleton: x0 with density sqrt(1-x0^2) exp(c x0), c > 0."""\n x0 = np.empty(c.shape)\n todo = np.ones(c.shape, bool)\n while todo.any():\n cc = c[todo]\n r = rng.random((4, cc.size))\n lam2 = -(np.log(r[0]) + np.cos(2 * np.pi * r[1]) ** 2 * np.log(r[2])) / (2 * cc)\n ok = r[3] ** 2 <= 1 - lam2\n idx = np.flatnonzero(todo)\n x0[idx[ok]] = 1 - 2 * lam2[ok]\n todo[idx[ok]] = False\n return x0\n\ndef vmf(c, mbar, rng):\n """Unit quaternions with density proportional to exp(c )."""\n shape = c.shape\n x0 = np.empty(shape)\n small = c < 0.3\n g = rng.standard_normal(shape + (4,))\n g /= np.linalg.norm(g, axis=-1, keepdims=True)\n x0[small] = g[small][:, 0]\n if (~small).any():\n x0[~small] = kp_x0(c[~small], rng)\n v = g[..., 1:]\n v = v / np.linalg.norm(v, axis=-1, keepdims=True)\n rr = np.sqrt(np.maximum(0.0, 1 - x0 ** 2))\n x = np.concatenate([x0[..., None], rr[..., None] * v], axis=-1)\n x[small] = g[small]\n return qmul(x, mbar)\n\ndef sample_coupled(a, m, group, rng, max_iter=3000):\n """Rows in blocks of `group` sample u with density exp(a ) by\n rejection from a common proposal exp(c ): identical rows give\n identical samples, nearby rows agree with high probability."""\n B, k = a.shape\n G = B // group\n a3 = a.reshape(G, group, k)\n m3 = m.reshape(G, group, k, 4)\n msum = m3.sum(axis=1)\n nrm = np.linalg.norm(msum, axis=-1)\n mbar = np.where(nrm[..., None] > 1e-9, msum / np.maximum(nrm, 1e-300)[..., None], m3[:, 0])\n cosang = np.einsum("gjkc,gkc->gjk", m3, mbar)\n c = np.maximum(0.0, (a3 * np.maximum(cosang, 0.0)).min(axis=1)) # (G, k)\n drift = a3[..., None] * m3 - c[:, None, :, None] * mbar[:, None]\n M = np.linalg.norm(drift, axis=-1) # (G, j, k)\n out = np.empty((G, group, k, 4))\n done = np.zeros((G, group, k), bool)\n for _ in range(max_iter):\n open_gk = ~done.all(axis=1)\n if not open_gk.any():\n break\n gi, ki = np.nonzero(open_gk)\n u = vmf(c[gi, ki], mbar[gi, ki], rng) # (q, 4)\n w = rng.random(gi.size)\n expo = np.einsum("qjc,qc->qj", drift[gi, :, ki], u) - M[gi, :, ki]\n acc = (np.log(w)[:, None] <= expo) & ~done[gi, :, ki]\n qi, ji = np.nonzero(acc)\n out[gi[qi], ji, ki[qi]] = u[qi]\n done[gi[qi], ji, ki[qi]] = True\n if not done.all(): # exact independent fallback keeps the marginals exact\n gi, ji, ki = np.nonzero(~done)\n out[gi, ji, ki] = vmf(a3[gi, ji, ki], m3[gi, ji, ki], rng)\n return out.reshape(B, k, 4)\n\n# ------------------------------------------------------------------- the probe\ndef main():\n ap = argparse.ArgumentParser()\n ap.add_argument("--beta", type=float, required=True, help="beta_W")\n ap.add_argument("--n", type=int, required=True)\n ap.add_argument("--margin", type=int, default=3)\n ap.add_argument("--therm", type=int, default=400)\n ap.add_argument("--sweeps", type=int, default=600)\n ap.add_argument("--samples", type=int, default=32)\n ap.add_argument("--angle", type=float, default=math.pi / 2)\n ap.add_argument("--seed", type=int, default=1)\n a = ap.parse_args()\n rng = np.random.default_rng(a.seed)\n n, w = a.n, a.margin\n L = n + 2 * w + 2\n if (w + 1) % 2:\n raise SystemExit("margin+1 must be even so that the cube starts on an even site")\n c0 = w + 1\n\n # thermalise the exterior\n box = Box(L, 1, rng)\n for _ in range(a.therm):\n box.heatbath(a.beta, rng)\n ext = box.U[0].copy()\n\n # the pair of chains lives on the cube with two layers around it\n off = c0 - 2\n P = n + 4\n ext = ext[:, off:off + P, off:off + P, off:off + P, off:off + P]\n idx = np.indices((P,) * 4)\n incube = np.ones((P,) * 4, bool)\n for d in range(4):\n incube &= (idx[d] >= 2) & (idx[d] < 2 + n)\n act = np.stack([SIGMA[tuple(idx % 2)] != mu for mu in range(4)])\n V = act & incube[None]\n\n # boundary links j = (y, mu): active, not in V, sharing a plaquette with V\n def at(a, shifts): # a(y + sum s e_d)\n for d, s in shifts:\n a = np.roll(a, -s, axis=d)\n return a\n near = np.zeros_like(V)\n for mu in range(4):\n for nu in range(4):\n if nu == mu:\n continue\n near[mu] |= at(V[nu], [(mu, 1)]) | V[nu] | at(V[nu], [(mu, 1), (nu, -1)]) \\\n | at(V[nu], [(nu, -1)]) | at(V[mu], [(nu, 1)]) | at(V[mu], [(nu, -1)])\n J = act & ~V & near\n jlist = np.argwhere(J)\n pick = jlist[rng.choice(len(jlist), size=min(a.samples, len(jlist)), replace=False)]\n\n B = 2 * len(pick)\n pair = Box(P, B, rng)\n pair.U[:] = ext[None]\n rot = np.array([math.cos(a.angle / 2), math.sin(a.angle / 2), 0.0, 0.0])\n dj = 2 * math.sin(a.angle / 2)\n for b, (mu, *x) in enumerate(pick):\n pair.U[2 * b + 1, mu, x[0], x[1], x[2], x[3]] = qmul(\n pair.U[2 * b + 1, mu, x[0], x[1], x[2], x[3]], rot)\n dist = []\n for t in range(a.sweeps):\n pair.heatbath(a.beta, rng, group=2, mask_extra=V)\n if t >= a.sweeps // 2:\n d = np.linalg.norm(pair.U[0::2] - pair.U[1::2], axis=-1) # (P,4,L,L,L,L)\n dist.append((d * V[None]).sum(axis=(1, 2, 3, 4, 5)))\n dist = np.array(dist)\n half = len(dist) // 2\n drift = (dist[half:].mean() - dist[:half].mean()) / dj\n infl = dist.mean(axis=0) / dj # per sampled j\n counts = len(jlist)\n Nn = (n // 2) ** 4\n # sum over all boundary links of all classes divided by 48 N_n: the class\n # average of K_c / N_n\n est = infl.mean() * counts / (48 * Nn)\n print(f"beta_W={a.beta} n={n} |V|={int(V.sum())} boundary={counts} "\n f"mean influence={infl.mean():.3f} (sd {infl.std():.3f}, max {infl.max():.3f}) "\n f"avg K_c/N_n={est:.3f} (late-minus-early {drift:+.3f})", flush=True)\n\nif __name__ == "__main__":\n main()\n', 'make_balaban.py': '"""Figure for the single-link coefficients across scales (ssec:bpbalaban).\n\nfig_bpbalaban: (a) one step of the straight-path map with blocks of side\nb = 4, drawn in a plane. Each coarse link is the ordered product of the b\nfine links of its path, marked at the link with base point b y + floor(b/2)\ne_nu. In the axial gauge the law of the block variables is the marginal on\nthe marks; two marks are at distance at least floor(b/2), and the influence\nof one mark on another runs through walks of fine links, each step weighted\nby a Dobrushin coefficient (Lemma lem:bpbalmarginal, Theorem thm:bpbalstep).\n(b) the lower bound 2 - 2 sqrt(3/B) - (3 pi^3/4) e^(1/2) B^(3/2) e^(-B),\nB = 6 beta_W, on the Dobrushin sum of the SU(2) Wilson measure that gauge\ncovariance forces (Corollary cor:bpbalwilson), against beta_W, with the\nthreshold 1 of the Dobrushin condition. (c) the lower bound\n2 - 4 (1 - eps_b)/pi, eps_b = (1 + 1/(4 beta_W))^(-b), at the coarsest scale,\nb = 2^k, along the illustrative tuning beta_W,k = 2 + (11/(3 pi^2)) k log 2\n(Proposition prop:bpbalrandom): above 1 the coarse law cannot satisfy the\nDobrushin condition; below 1 gauge covariance no longer excludes it, and\nthe bound tends to 2 - 4/pi.\n\nRun from this directory: python3 make_balaban.py."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom matplotlib.patches import FancyArrowPatch\nfrom make_figures import save\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY, GOLD = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\', \'#d4a017\'\n\n\ndef wilson_bound(bw):\n B = 6 * bw\n return 2 - 2 * np.sqrt(3 / B) - 0.75 * np.pi ** 3 * np.exp(0.5) * B ** 1.5 * np.exp(-B)\n\n\ndef coarse_bound(k, beta0=2.0):\n beta = beta0 + 11 / (3 * np.pi ** 2) * k * np.log(2)\n eps = (1 + 1 / (4 * beta)) ** (-(2.0 ** k))\n return 2 - 4 * (1 - eps) / np.pi\n\n\ndef fig_bpbalaban():\n fig = plt.figure(figsize=(10.0, 3.5))\n ax = fig.add_axes([0.01, 0.06, 0.34, 0.86])\n b, nb = 4, 3\n n = b * nb\n for i in range(n + 1):\n ax.plot([0, n], [i, i], color=GREY, lw=0.4, zorder=1)\n ax.plot([i, i], [0, n], color=GREY, lw=0.4, zorder=1)\n marks = []\n for yx in range(nb):\n for yy in range(nb):\n x0, y0 = b * yx, b * yy\n ax.plot([x0, x0 + b], [y0, y0], color=INK, lw=1.6, zorder=2)\n ax.plot([x0, x0], [y0, y0 + b], color=INK, lw=1.6, zorder=2)\n mx = (x0 + b // 2, y0)\n my = (x0, y0 + b // 2)\n ax.plot([mx[0], mx[0] + 1], [mx[1], mx[1]], color=RED, lw=3.2, zorder=3, solid_capstyle=\'butt\')\n ax.plot([my[0], my[0]], [my[1], my[1] + 1], color=RED, lw=3.2, zorder=3, solid_capstyle=\'butt\')\n marks += [mx, my]\n ax.plot([0, n], [n, n], color=INK, lw=1.6); ax.plot([n, n], [0, n], color=INK, lw=1.6)\n # a walk from mark e to mark j through unmarked fine links\n walk = [(6.5, 4.0), (7.0, 4.5), (7.0, 5.5), (7.5, 6.0), (8.0, 6.5)]\n for (p, q) in zip(walk[:-1], walk[1:]):\n ax.add_patch(FancyArrowPatch(p, q, arrowstyle=\'-|>\', mutation_scale=8, color=BLUE, lw=1.1, zorder=4))\n ax.text(6.3, 3.35, r\'$l(e)$\', color=RED, fontsize=9)\n ax.text(8.25, 6.55, r\'$l(j)$\', color=RED, fontsize=9)\n ax.text(8.6, 4.55, r\'$C_{ek_1}C_{k_1k_2}\\cdots$\', color=BLUE, fontsize=8.5)\n ax.annotate(\'\', xy=(4.0, -0.55), xytext=(8.0, -0.55), arrowprops=dict(arrowstyle=\'<->\', color=INK, lw=0.8))\n ax.text(5.3, -1.25, r\'side $b$\', fontsize=8.5)\n ax.set_xlim(-0.6, n + 0.8); ax.set_ylim(-1.6, n + 0.9); ax.set_aspect(\'equal\'); ax.axis(\'off\')\n ax.text(-0.5, n + 0.4, \'(a)\', fontsize=11)\n ax.text(0.0, -1.25, \'marks\', color=RED, fontsize=8.5)\n\n bx = fig.add_axes([0.42, 0.17, 0.25, 0.70])\n bw = np.linspace(0.6, 12, 400)\n bx.plot(bw, wilson_bound(bw), color=INK, lw=1.5, label=\'lower bound on $c_\\\\mu$\')\n bx.axhline(1, color=RED, lw=0.9, ls=\'--\', label=\'Dobrushin threshold\')\n bx.axvline(8 / 3, color=GREY, lw=0.8, ls=\':\')\n bx.text(8 / 3 + 0.25, 1.85, r\'$\\beta_W=\\frac{8}{3}$\', fontsize=8.5, color=\'#444444\')\n bx.set_xlabel(r\'$\\beta_W$\'); bx.set_ylim(0, 2.05)\n bx.set_title(r\'(b) finest level, $\\mathrm{SU}(2)$ Wilson\', fontsize=10, loc=\'left\')\n bx.legend(fontsize=8, frameon=False, loc=\'lower right\', bbox_to_anchor=(1.0, 0.12))\n\n cx = fig.add_axes([0.73, 0.17, 0.25, 0.70])\n ks = np.arange(1, 13)\n cx.plot(ks, coarse_bound(ks), \'o-\', color=BLUE, lw=1.3, ms=3.5, label=\'lower bound on $c$\')\n cx.axhline(1, color=RED, lw=0.9, ls=\'--\')\n cx.axhline(2 - 4 / np.pi, color=GREY, lw=0.8, ls=\':\')\n cx.text(7.2, 2 - 4 / np.pi - 0.17, r\'$2-4/\\pi$\', fontsize=8.5, color=\'#444444\')\n cx.set_xticks([2, 4, 6, 8, 10, 12]); cx.set_xlabel(r\'$k$ (blocks of side $2^k$)\'); cx.set_ylim(0, 2.05)\n cx.set_title(r\'(c) coarsest scale along the tuning\', fontsize=10, loc=\'left\')\n cx.legend(fontsize=8, frameon=False, loc=\'upper right\')\n save(fig, \'fig_bpbalaban.png\')\n\n\nif __name__ == \'__main__\':\n fig_bpbalaban()\n', 'make_bpweak.py': '"""Figures for the averaged condition at strong coupling, at fixed cube size\nand at weak coupling, and for the derivative in the ends.\n\nfig_bpranges: (a) the bound of Theorem thm:bpfixed(ii),\nlog10(38400 n^4 (log beta + 6.11)/beta), as a surface over the cube side n\nand log10 beta, with the plane varpi = 1; (b) the plane of the Wilson\ncoupling beta_W = 4 beta and the cube side n for SU(2): the strong-coupling\nrange of Corollary cor:bpranges, the region where Theorem thm:bpfixed\nexcludes BP(n, 1/2) on the torus of side 2n+4, and the continuum tuning\nn ~ exp(3 pi^2 beta_W / 11), schematic (the power prefactor is omitted).\n\nfig_bpsectors: (a) a three-dimensional section of the torus with the slices\n{y_nu = t}; the centre twist multiplies the links that cross one slice by z,\na Polyakov loop crosses every slice once (charged), a local box misses a\nslice (neutral) (Proposition prop:bpcentre); (b) the spectral measures of the\ncube chain, schematic: a local function has no mass in (1 - epsilon, 1]\nunder BP_loc, while charged functions may carry mass near 1\n(Theorem thm:bplocal, Corollary cor:bpcharged).\n\nfig_endslinear: log10 of the two derivative constants of Theorem\nthm:endlinear over beta_W and the tie length b_tie: L_* with the factor\ne^{72 beta_W} (using A_tie < 1.5756 b_tie) and L_lin, linear in beta_W.\n\nfig_bpneutral: (a) the great circle of SU(2) through I, u, -I, -u with the\nholonomy flow sin(2 theta) d/d theta of Lemma lem:bpflow, which fixes the\ncentre and the traceless elements; (b) the Haar law of T = Tr P_0, density\nsqrt(4 - T^2)/(2 pi), and the weight T^2 (4 - T^2) of Theorem thm:bpneutral,\nwhich vanishes at T in {-2, 0, 2}.\n\nRun from this directory: python3 make_bpweak.py."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d.art3d import Poly3DCollection, Line3DCollection\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY, GOLD = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\', \'#d4a017\'\n\n\ndef fig_bpranges():\n fig = plt.figure(figsize=(9.6, 4.2))\n ax = fig.add_axes([0.0, 0.02, 0.5, 0.96], projection=\'3d\')\n n = np.linspace(2, 40, 60)\n lb = np.linspace(4, 16, 60)\n N, LB = np.meshgrid(n, lb)\n beta = 10.0 ** LB\n Z = np.log10(38400 * N ** 4 * (np.log(beta) + 6.11) / beta)\n cols = np.where(Z[..., None] < 0, np.array([0.75, 0.22, 0.17, 0.85]), np.array([0.23, 0.44, 0.71, 0.55]))\n ax.plot_surface(N, LB, Z, facecolors=cols, rstride=1, cstride=1, linewidth=0, antialiased=True, shade=False)\n P = np.zeros_like(Z)\n ax.plot_surface(N, LB, P, color=GREY, alpha=0.18, linewidth=0)\n nn = np.linspace(2, 40, 200)\n lbc = []\n for v in nn:\n f = lambda t: 38400 * v ** 4 * (np.log(10 ** t) + 6.11) / 10 ** t - 1\n lo, hi = 4.0, 16.0\n if f(lo) < 0 or f(hi) > 0:\n lbc.append(np.nan); continue\n for _ in range(60):\n mid = (lo + hi) / 2\n lo, hi = (mid, hi) if f(mid) > 0 else (lo, mid)\n lbc.append(lo)\n ax.plot(nn, lbc, 0 * nn, color=INK, lw=1.4)\n ax.set_xlabel(\'cube side $n$\', labelpad=2)\n ax.set_ylabel(r\'$\\log_{10}\\beta$\', labelpad=2)\n ax.set_zlabel(r\'$\\log_{10}$ bound on $\\varpi$\', labelpad=2)\n ax.set_box_aspect((1, 1, 0.7))\n ax.view_init(elev=24, azim=-128)\n ax.tick_params(labelsize=7, pad=0)\n fig.text(0.03, 0.92, \'(a)\', fontsize=11)\n fig.text(0.08, 0.86, r\'red: the bound is below $\\varpi=1$\', color=RED, fontsize=8)\n\n bx = fig.add_axes([0.6, 0.15, 0.37, 0.75])\n bw = np.logspace(-1.5, 14.0, 800)\n b = bw / 4.0\n # Theorem thm:bpfixed excludes BP(n, 1/2) when 38400 n^4 (log b + 6.11)/b < 1/2, b >= 1\n with np.errstate(invalid=\'ignore\'):\n nobs = np.where(b >= 1, (b / (2 * 38400 * (np.log(b) + 6.11))) ** 0.25, np.nan)\n bx.fill_between(bw, 2, np.where(nobs > 2, nobs, 2), where=nobs > 2, color=RED, alpha=0.25, lw=0)\n bx.plot(bw, nobs, color=RED, lw=1.2)\n bx.axvspan(bw[0], 2 / 9, color=GREEN, alpha=0.18, lw=0)\n tun = 2.0 * np.exp(np.minimum(3 * np.pi ** 2 * bw / 11, 50.0))\n bx.plot(bw, tun, color=BLUE, lw=1.3, ls=\'--\')\n bx.set_xscale(\'log\'); bx.set_yscale(\'log\')\n bx.set_xlim(bw[0], bw[-1]); bx.set_ylim(2, 1e4)\n bx.set_xlabel(r\'$\\beta_W$ for $\\mathrm{SU}(2)$\'); bx.set_ylabel(\'cube side $n$\')\n bx.text(0.075, 60, \'BP proved\', color=GREEN, fontsize=8, rotation=90, ha=\'center\')\n bx.text(1e10, 3.0, \'BP$(n,1/2)$ fails\\non $\\\\Lambda_{2n+4}$\', color=RED, fontsize=8)\n bx.text(12.0, 1.5e3, \'tuning\', color=BLUE, fontsize=8)\n bx.text(1e5, 400, \'open\', color=INK, fontsize=9)\n for sp in (\'top\', \'right\'):\n bx.spines[sp].set_visible(False)\n fig.text(0.55, 0.92, \'(b)\', fontsize=11)\n save(fig, \'fig_bpranges.png\')\n\n\ndef fig_bpsectors():\n fig = plt.figure(figsize=(9.6, 4.2))\n ax = fig.add_axes([0.0, 0.0, 0.52, 1.0], projection=\'3d\')\n clean3d(ax)\n ax.computed_zorder = False\n L = 6\n # slices {y_0 = t}, drawn as planes x = t\n for t in range(L + 1):\n v = [(t, 0, 0), (t, L, 0), (t, L, L), (t, 0, L)]\n col = GOLD if t == 2 else GREY\n al = 0.32 if t == 2 else 0.07\n ax.add_collection3d(Poly3DCollection([v], facecolor=col, edgecolor=GREY, lw=0.4, alpha=al))\n # links crossing slice t=2 in direction 0: from x=2 to x=3 are multiplied by z\n segs = [[(2, y, z), (3, y, z)] for y in range(L + 1) for z in range(L + 1)]\n ax.add_collection3d(Line3DCollection(segs, colors=GOLD, lw=1.0))\n # Polyakov loop in direction 0\n ax.plot([0, L], [4.5, 4.5], [4.5, 4.5], color=RED, lw=2.6)\n ax.text(L + 0.2, 4.5, 4.9, r\'Polyakov loop: $\\mathcal{A}_{e_0}$\', color=RED, fontsize=9)\n # local box avoiding slice t=2\n b0, s = 3.5, 1.6\n cub = np.array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0], [0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1]]) * s + np.array([b0, 0.8, 0.8])\n faces = [[cub[i] for i in f] for f in ([0, 1, 2, 3], [4, 5, 6, 7], [0, 1, 5, 4], [2, 3, 7, 6], [1, 2, 6, 5], [0, 3, 7, 4])]\n ax.add_collection3d(Poly3DCollection(faces, facecolor=GREEN, edgecolor=INK, lw=0.5, alpha=0.45))\n ax.text(b0 + s + 0.3, 0.4, 0.5, r\'local box: $\\mathcal{A}_0$\', color=GREEN, fontsize=9)\n ax.text(-1.0, 0.0, -1.6, r\'twist $Z^0_t$: links across $\\{y_0=t\\}$ times $z$\', color=GOLD, fontsize=9)\n ax.set_xlim(0, L); ax.set_ylim(0, L); ax.set_zlim(0, L)\n ax.view_init(elev=20, azim=-62)\n fig.text(0.03, 0.92, \'(a)\', fontsize=11)\n\n bx = fig.add_axes([0.6, 0.18, 0.37, 0.68])\n lam = np.linspace(0, 1, 500)\n eps = 0.18\n loc = np.exp(-((lam - 0.42) / 0.16) ** 2) * (lam <= 1 - eps)\n chg = 0.55 * np.exp(-((lam - 0.97) / 0.02) ** 2) + 0.4 * np.exp(-((lam - 0.5) / 0.2) ** 2)\n bx.fill_between(lam, 0, loc, color=GREEN, alpha=0.45, lw=0, label=\'local, neutral\')\n bx.plot(lam, chg, color=RED, lw=1.3, label=\'charged\')\n bx.axvspan(1 - eps, 1, color=GREY, alpha=0.22, lw=0)\n bx.text(1 - eps + 0.01, 1.05, r\'$(1-\\epsilon,1]$\', fontsize=8)\n bx.set_xlim(0, 1.02); bx.set_ylim(0, 1.2)\n bx.set_xlabel(r\'spectrum of $\\mathcal{K}$\'); bx.set_yticks([])\n bx.legend(loc=\'upper left\', fontsize=8, frameon=False)\n for sp in (\'top\', \'right\', \'left\'):\n bx.spines[sp].set_visible(False)\n fig.text(0.55, 0.92, \'(b)\', fontsize=11)\n save(fig, \'fig_bpsectors.png\')\n\n\ndef fig_endslinear():\n fig = plt.figure(figsize=(7.4, 4.6))\n ax = fig.add_axes([0.0, 0.0, 1.0, 1.0], projection=\'3d\')\n bw = np.linspace(0.0, 0.6, 50)\n bt = np.linspace(0.0, 20.0, 50)\n B, T = np.meshgrid(bw, bt)\n Ls = np.log10(128.07 * B + (180.4 + 50.6 * 1.5756 * T) * np.exp(72 * B))\n Ll = np.log10(7192 + 443620 * B + T * (79.69 + 27216 * B))\n ax.plot_surface(B, T, Ls, color=RED, alpha=0.8, linewidth=0)\n ax.plot_surface(B, T, Ll, color=BLUE, alpha=0.8, linewidth=0)\n ax.set_xlabel(r\'$\\beta_W$\', labelpad=2)\n ax.set_ylabel(r\'$\\mathfrak{b}_{\\mathrm{tie}}$\', labelpad=2)\n ax.set_zlabel(r\'$\\log_{10}L$\', labelpad=2)\n ax.text(0.6, 0, 20, r\'$L_*$ (factor $e^{72\\beta_W}$)\', color=RED, fontsize=9)\n ax.text(0.6, 20, 4.2, r\'$L_{\\mathrm{lin}}$\', color=BLUE, fontsize=9)\n ax.set_box_aspect((1, 1, 0.75))\n ax.view_init(elev=18, azim=-50)\n ax.tick_params(labelsize=7, pad=0)\n save(fig, \'fig_endslinear.png\')\n\n\ndef fig_bpneutral():\n fig = plt.figure(figsize=(9.6, 4.0))\n ax = fig.add_axes([0.02, 0.06, 0.42, 0.88])\n th = np.linspace(0, 2 * np.pi, 400)\n ax.plot(np.cos(th), np.sin(th), color=GREY, lw=1.2)\n for t in np.linspace(0, 2 * np.pi, 24, endpoint=False) + np.pi / 24:\n v = np.sin(2 * t) * 0.32\n x, y = np.cos(t), np.sin(t)\n ax.annotate(\'\', xy=(x - v * np.sin(t), y + v * np.cos(t)), xytext=(x, y),\n arrowprops=dict(arrowstyle=\'->\', color=BLUE, lw=1.1))\n for (x, y, lab, c) in ((1, 0, r\'$I$\', RED), (-1, 0, r\'$-I$\', RED), (0, 1, r\'$u$\', GOLD), (0, -1, r\'$-u$\', GOLD)):\n ax.plot(x, y, \'o\', color=c, ms=7, zorder=5)\n ax.text(1.22 * x - (0.06 if x < 0 else 0), 1.18 * y - 0.04, lab, color=c, fontsize=11, ha=\'center\')\n ax.text(0, 0.05, r\'$\\cos\\theta\\,I+\\sin\\theta\\,u$\', ha=\'center\', fontsize=10)\n ax.text(0, -0.2, r\'velocity $\\sin 2\\theta\\,\\partial_\\theta$\', ha=\'center\', fontsize=9, color=BLUE)\n ax.set_xlim(-1.5, 1.5); ax.set_ylim(-1.4, 1.4); ax.set_aspect(\'equal\'); ax.axis(\'off\')\n fig.text(0.03, 0.92, \'(a)\', fontsize=11)\n\n bx = fig.add_axes([0.56, 0.16, 0.41, 0.72])\n T = np.linspace(-2, 2, 600)\n dens = np.sqrt(np.clip(4 - T ** 2, 0, None)) / (2 * np.pi)\n w = T ** 2 * (4 - T ** 2)\n bx.fill_between(T, 0, dens, color=GREY, alpha=0.35, lw=0, label=r\'Haar law of $T$\')\n bx.plot(T, w / 16, color=GREEN, lw=1.6, label=r\'$T^2(4-T^2)/16$\')\n for t0 in (-2, 0, 2):\n bx.plot(t0, 0, \'o\', color=RED, ms=6, clip_on=False, zorder=5)\n bx.text(0.0, 0.045, \'exceptional set\', color=RED, fontsize=8, ha=\'center\')\n bx.set_xlim(-2.1, 2.1); bx.set_ylim(0, 0.42)\n bx.set_xlabel(r\'$T=\\mathrm{Tr}\\,P_0$\'); bx.set_yticks([])\n bx.legend(loc=\'upper right\', fontsize=8, frameon=False)\n for sp in (\'top\', \'right\', \'left\'):\n bx.spines[sp].set_visible(False)\n fig.text(0.53, 0.92, \'(b)\', fontsize=11)\n save(fig, \'fig_bpneutral.png\')\n\n\nif __name__ == \'__main__\':\n fig_bpranges()\n fig_bpsectors()\n fig_endslinear()\n fig_bpneutral()\n', 'make_centreodd.py': '"""Figure for Theorem thm:centreodd and Lemma lem:boxenergy: (a) the spatial\ntorus (Z/LZ)^3 of the box drawn as a cube with identified faces, the winding\nloops W_1 and W_2, and the plane x_1 = const across which the centre map\nzeta_1 multiplies the links of direction 1 by -1, so that Tr W_1 and\nTr W_1 W_2 change sign; (b) the energy bound eps(b) = 3(log b + 5)/(2b) of\nLemma lem:boxenergy against the threshold 1/(1600 L^4) of\nTheorem thm:centreodd(ii) at L = 3.\nRun from this directory: python3 make_centreodd.py. Writes fig_centreodd.png."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d.art3d import Poly3DCollection\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\'\n\nfig = plt.figure(figsize=(9.0, 3.8))\nax = fig.add_axes([-0.02, 0.06, 0.52, 0.96], projection=\'3d\')\nclean3d(ax)\nax.computed_zorder = False\nL = 3\nfor i in range(L + 1):\n for j in range(L + 1):\n for (a, b_, c) in (((0, L), i, j), (i, (0, L), j), (i, j, (0, L))):\n xs = a if isinstance(a, tuple) else (a, a)\n ys = b_ if isinstance(b_, tuple) else (b_, b_)\n zs = c if isinstance(c, tuple) else (c, c)\n ax.plot(xs, ys, zs, color=GREY, lw=0.5, zorder=1)\nplane = [[(1.5, 0, 0), (1.5, L, 0), (1.5, L, L), (1.5, 0, L)]]\nax.add_collection3d(Poly3DCollection(plane, facecolor=\'#f6d5d0\', edgecolor=RED, alpha=0.5, lw=1.0))\nax.plot([0, L], [1, 1], [2, 2], color=BLUE, lw=2.4, zorder=5)\nax.plot([1, 1], [0, L], [2, 2], color=GREEN, lw=2.4, zorder=5)\nax.scatter([1.5], [1], [2], color=RED, s=28, zorder=6)\nax.text(L + 0.1, 1, 2.15, r\'$W_1$\', color=BLUE, fontsize=11, zorder=7)\nax.text(1, L + 0.15, 2.2, r\'$W_2$\', color=GREEN, fontsize=11, zorder=7)\nfig.text(0.04, 0.02, r\'shaded plane: $\\zeta_1$ multiplies the links of direction 1 crossing it by $-1$\', color=RED, fontsize=9)\nax.view_init(22, -62)\nax.set_xlim(0, L); ax.set_ylim(0, L); ax.set_zlim(0, L)\nax.set_title(r\'(a) the box $(\\mathbb{Z}/L\\mathbb{Z})^3$ and the winding loops\', fontsize=10, y=0.97)\n\nbx = fig.add_axes([0.6, 0.17, 0.37, 0.7])\nb = np.logspace(0, 9, 400)\neps = 3 * (np.log(b) + 5) / (2 * b)\nthr = 1 / (1600 * L ** 4)\nbx.loglog(b, eps, color=BLUE, lw=1.6, label=r\'$\\varepsilon(b)=3(\\log b+5)/(2b)$\')\nbx.axhline(thr, color=RED, lw=1.2, ls=\'--\')\nbstar = b[np.argmax(eps <= thr)]\nbx.axvline(bstar, color=GREY, lw=0.8, ls=\':\')\nbx.text(1.5, thr * 1.6, r\'$1/(1600L^4)$, $L=3$\', color=RED, fontsize=9)\nbx.set_xlabel(r\'coupling $b$\')\nbx.spines[[\'top\', \'right\']].set_visible(False)\nbx.legend(frameon=False, fontsize=9, loc=\'upper right\')\nbx.set_title(r\'(b) the plaquette energy of the box\', fontsize=10)\nsave(fig, \'fig_centreodd.png\')\nprint(\'first b on the grid with eps <= threshold:\', \'%.3g\' % bstar)\n', 'make_certificate.py': '"""Figure of Appendix "app:certificate": (a) the least eigenvalue of the plaquette matrix M_p(phi)\nover the torus of phases, for the plaquette whose minimum is smallest; (b) the bracket of the definition\nof h for the 48 free links of a period cell, against 9 + sqrt(17), 14.384 and 29/2; (c) the constants of\nthe block gap, Theorem "blockgap" (52), Proposition "blockgapsharp" (5000/537) and the bulk Bloch value\n1/c* = 1/0.1074877694868. Run from this directory: python3 make_certificate.py (about one minute; it\nimports strong-coupling/gauge-fixed/checks/romanov/romanov_certificate.py and its data). The\neigenvalues are in floating point. Writes fig_certificate.png."""\nimport os, sys\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom make_figures import save\n\nHERE = os.path.dirname(os.path.abspath(__file__))\nROM = os.path.join(HERE, \'..\', \'..\', \'gauge-fixed\', \'checks\', \'romanov\')\nsys.path.insert(0, ROM)\nsys.argv = [sys.argv[0], os.path.join(ROM, \'cert4d_h14.42.json\')]\nimport romanov_certificate as rc # noqa: E402\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, ORANGE, GREEN, INK = \'#3b6fb6\', \'#c0392b\', \'#e67e22\', \'#2e8b57\', \'#222222\'\n\n\ndef plaquette(j):\n p, c, f = rc.PL[j]\n k = [2 * float(rc.G[s][r][q]) for s, r, q in c]\n idx = [4 * i + q for i in f for q in range(4)]\n R = lambda M: M[np.ix_(idx, idx)]\n D = np.zeros((16, 16))\n for i in f:\n D[4 * i:4 * i + 4, 4 * i:4 * i + 4] = float(rc.A[j][i]) * np.eye(4)\n K0 = R(D - k[0] * rc.C14 - k[1] * rc.C12 - k[3] * rc.C34 - k[2] * rc.CB[0])\n F = [R(x) for x in rc.FB]\n\n def lmin(p1, p2):\n dl = p1 - p2\n M = (K0[None] - np.cos(p1)[:, None, None] * F[0] - np.sin(p1)[:, None, None] * F[1]\n - np.cos(p2)[:, None, None] * F[2] - np.sin(p2)[:, None, None] * F[3]\n - k[2] * (np.cos(dl)[:, None, None] * R(rc.CB[1]) + np.sin(dl)[:, None, None] * R(rc.CB[2])))\n return np.linalg.eigvalsh(M)[:, 0]\n return lmin\n\n\nn = 96\nt = np.linspace(0, 2 * np.pi, n + 1)\nP1, P2 = np.meshgrid(t, t, indexing=\'ij\')\nbest = None\nfor j in range(len(rc.PL)):\n lam = plaquette(j)(P1.ravel(), P2.ravel()).reshape(P1.shape)\n if best is None or lam.min() < best[1].min():\n best = (j, lam)\nj, lam = best\nprint(\'plaquette\', j, \'least eigenvalue on the grid\', lam.min())\n\nfig = plt.figure(figsize=(9.6, 3.2))\nax = fig.add_axes([-0.03, 0.0, 0.38, 1.0], projection=\'3d\')\nax.set_box_aspect((1, 1, 0.75))\nax.plot_surface(P1, P2, lam, cmap=\'viridis\', rstride=2, cstride=2, lw=0.1, edgecolor=\'#444444\', alpha=0.95)\ni0 = np.unravel_index(lam.argmin(), lam.shape)\nax.scatter([P1[i0]], [P2[i0]], [lam[i0]], color=RED, s=18, depthshade=False)\nax.set_xlabel(r\'$\\varphi_1$\', labelpad=-6)\nax.set_ylabel(r\'$\\varphi_2$\', labelpad=-6)\nax.set_xticks([0, np.pi, 2 * np.pi]); ax.set_xticklabels([\'0\', r\'$\\pi$\', r\'$2\\pi$\'])\nax.set_yticks([0, np.pi, 2 * np.pi]); ax.set_yticklabels([\'0\', r\'$\\pi$\', r\'$2\\pi$\'])\nax.tick_params(pad=-2, labelsize=8)\nax.view_init(26, -55)\nax.set_title(r\'(a) least eigenvalue of $M_p(\\varphi)$\', fontsize=10, y=0.97)\n\ntot = sorted(float(v) for v in rc.tot.values())\nax2 = fig.add_axes([0.40, 0.18, 0.27, 0.68])\nax2.bar(range(len(tot)), tot, color=BLUE, width=0.8)\nfor y, col, lab in ((14.5, RED, r\'$\\frac{29}{2}$\'), (14.420001, ORANGE, r\'$14.420001$\'),\n (14.384, GREEN, r\'$14.384$\'), (9 + np.sqrt(17), INK, r\'$9+\\sqrt{17}$\')):\n ax2.axhline(y, color=col, lw=1.0, ls=\'--\' if col != ORANGE else \'-\')\n ax2.text(len(tot) + 0.5, y, lab, color=col, fontsize=8, va=\'center\')\nax2.set_ylim(12.6, 14.7)\nax2.set_xlim(-1, len(tot))\nax2.set_xlabel(\'free links of a period cell\')\nax2.set_title(\'(b) totals of the certificate\', fontsize=10)\nax2.spines[\'top\'].set_visible(False); ax2.spines[\'right\'].set_visible(False)\n\nax3 = fig.add_axes([0.80, 0.18, 0.18, 0.68])\nvals = [(1 / 0.1074877694868, GREEN, \'Bloch\'), (5000 / 537, ORANGE, r\'$\\frac{5000}{537}$\'), (52, RED, \'52\')]\nfor x, (v, col, lab) in enumerate(vals):\n ax3.bar(x, v, color=col, width=0.6)\n ax3.text(x, v * 1.08, lab, ha=\'center\', fontsize=9, color=col)\nax3.set_yscale(\'log\')\nax3.set_ylim(5, 100)\nax3.set_xticks([])\nax3.set_ylabel(r\'$C$ in $\\sum\\phi^2\\leq C\\,Q$\')\nax3.set_title(\'(c) block gap\', fontsize=10)\nax3.spines[\'top\'].set_visible(False); ax3.spines[\'right\'].set_visible(False)\nsave(fig, \'fig_certificate.png\')\n', 'make_chessceiling.py': '"""Figure for Theorem thm:chessceiling and Corollary cor:chessceiling:\n(a) the dyadic scales stacked as plates of side 2^j: the scales at which a\nchessboard bound for the islands is below one (green), and the scale of the\ncube of D(n, alpha) (red), at least three dyadic scales higher for the labels\nof the island theorems and at least twenty for the calm labels;\n(b) the condition 16^{j+1} < beta_W eta^2 / (96 (log beta_W + C_0)) of part\n(ii): the left side grows by 16 per scale and meets the right side, which does\nnot depend on j, before the scale of the cube. Schematic, not to scale.\nRun from this directory: python3 make_chessceiling.py. Writes fig_chessceiling.png."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d.art3d import Poly3DCollection\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\'\n\nfig = plt.figure(figsize=(9.0, 4.0))\nax = fig.add_axes([0.12, 0.0, 0.46, 1.0], projection=\'3d\')\nclean3d(ax)\nlevels = 7\njmax = 3\nfor j in range(levels):\n side = 0.8 + 0.55 * j\n z = 0.9 * j\n c = -side / 2\n v = [(c, c, z), (c + side, c, z), (c + side, c + side, z), (c, c + side, z)]\n if j <= jmax:\n col, al = GREEN, 0.55\n elif j < levels - 1:\n col, al = GREY, 0.25\n else:\n col, al = RED, 0.55\n ax.add_collection3d(Poly3DCollection([v], facecolor=col, edgecolor=INK, lw=0.5, alpha=al))\n ax.text(c + side + 0.1, c + side / 2, z, r\'$j=%s$\' % (str(j) if j < levels - 1 else r\'j_{\\rm cube}\'), fontsize=8, color=INK)\nfig.text(0.02, 0.25, \'bound below one\', color=GREEN, fontsize=9)\nfig.text(0.02, 0.56, r\'$\\geq 3$ scales (islands)\' + \'\\n\' + r\'$\\geq 20$ scales (calm labels)\', color=INK, fontsize=9)\nfig.text(0.02, 0.80, \'cube of $D(n,\\\\alpha)$\', color=RED, fontsize=9)\nax.set_xlim(-2.5, 2.5); ax.set_ylim(-2.5, 2.5); ax.set_zlim(0, 5.6)\nax.view_init(elev=18, azim=-55)\nfig.text(0.02, 0.93, \'(a)\', fontsize=11)\n\nbx = fig.add_axes([0.6, 0.15, 0.37, 0.75])\nj = np.arange(0, 7)\nlhs = 16.0 ** (j + 1)\nrhs = 16.0 ** 4.4\nbx.semilogy(j, lhs, color=BLUE, marker=\'o\', ms=4, label=r\'$16^{j+1}$\')\nbx.axhline(rhs, color=GREEN, lw=1.2, label=r\'$\\beta_W\\tilde\\eta^{2}/(96(\\log\\beta_W+C_0))$\')\nbx.axvspan(-0.3, 3.4, color=GREEN, alpha=0.12)\nbx.axvline(6, color=RED, lw=1.2, ls=\'--\')\nbx.text(6.05, 30, r\'$j_{\\rm cube}$\', color=RED)\nbx.set_xlabel(r\'scale $j$\'); bx.set_xlim(-0.3, 6.8)\nbx.legend(loc=\'upper left\', fontsize=8, frameon=False)\nfor sp in (\'top\', \'right\'):\n bx.spines[sp].set_visible(False)\nfig.text(0.56, 0.93, \'(b)\', fontsize=11)\nsave(fig, \'fig_chessceiling.png\')\n', 'make_continuum.py': '"""Figures for the averaged condition across scales and for the continuum\nlimit at separated points.\n\nfig_bptower: (a) three lattices of spacings a_0, a_0/b, a_0/b^2 drawn as\nstacked planes, each with a cube of the same physical side ell; the\naveraged condition descends to block variables for every gauge-invariant\nmeasure (Theorem thm:bpdescent, green arrows) and climbs one scale under the\nsplit inequality S (Theorem thm:bpup, gold arrows). (b) the measures on the\nfine lattice: Haar refinements satisfy S (Theorem thm:bprefine), the Wilson\nmeasures at beta != 0 are not Haar refinements (Proposition\nprop:bpnotrefine); for them S holds at strong coupling\n(Theorem thm:bpsplitstrong) and is an input at weak coupling.\n\nfig_limitlogic: the conditions on the lattice fields and what they give in\nthe limit, in three layers: inputs on reflected norms of packets (bottom),\nlattice bounds (middle), properties of the Schwinger functions (top).\nSolid arrows are implications proved in the text, crossed arrows are\nnon-implications proved by examples.\n\nRun from this directory: python3 make_continuum.py."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom matplotlib.patches import FancyBboxPatch, Polygon, FancyArrowPatch\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY, GOLD = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\', \'#d4a017\'\n\n\ndef _plane(ax, z, n, side, colour):\n h = side / n\n xs = np.linspace(0, side, n + 1)\n for x in xs:\n ax.plot([x, x], [0, side], [z, z], color=GREY, lw=0.35, alpha=0.8)\n ax.plot([0, side], [x, x], [z, z], color=GREY, lw=0.35, alpha=0.8)\n X, Y = np.meshgrid([0, side], [0, side])\n ax.plot_surface(X, Y, np.full_like(X, z, dtype=float), color=colour, alpha=0.10, linewidth=0, shade=False)\n return h\n\n\ndef _cube(ax, x0, y0, z0, s, hgt, colour):\n v = np.array([[x0, y0], [x0 + s, y0], [x0 + s, y0 + s], [x0, y0 + s], [x0, y0]])\n ax.plot(v[:, 0], v[:, 1], [z0] * 5, color=colour, lw=1.6)\n ax.plot(v[:, 0], v[:, 1], [z0 + hgt] * 5, color=colour, lw=1.0, alpha=0.8)\n for p in v[:4]:\n ax.plot([p[0], p[0]], [p[1], p[1]], [z0, z0 + hgt], color=colour, lw=1.0, alpha=0.8)\n\n\ndef fig_bptower():\n fig = plt.figure(figsize=(9.6, 4.4))\n ax = fig.add_axes([0.0, 0.0, 0.56, 1.0], projection=\'3d\')\n clean3d(ax)\n ax.set_box_aspect((1, 1, 1.05))\n side, ell = 8.0, 3.0\n levels = [(0.0, 8, r\'$a_0$\'), (2.2, 16, r\'$a_0/b$\'), (4.4, 32, r\'$a_0/b^2$\')]\n for z, n, lab in levels:\n h = _plane(ax, z, n, side, BLUE)\n _cube(ax, 2.5, 2.5, z, ell, 0.35, RED)\n ax.text(side + 0.6, 0, z, lab, fontsize=10, color=INK)\n ax.text(2.5 + ell + 0.3, 2.5, z + 0.05, r\'$n=%d$\' % int(round(ell / h)), fontsize=9, color=RED)\n for (z0, _, _), (z1, _, _) in zip(levels[:-1], levels[1:]):\n ax.quiver(0.4, 0.4, z1 - 0.15, 0, 0, -(z1 - z0) + 0.45, color=GREEN, lw=1.8, arrow_length_ratio=0.18)\n ax.quiver(7.2, 7.2, z0 + 0.25, 0, 0, (z1 - z0) - 0.45, color=GOLD, lw=1.8, arrow_length_ratio=0.18)\n fig.text(0.01, 0.47, \'descent\\n(every\\nmeasure)\', color=GREEN, fontsize=8.5)\n fig.text(0.445, 0.50, \'upward step\\n(under S)\', color=GOLD, fontsize=8.5)\n ax.text2D(0.03, 0.93, \'(a)\', transform=ax.transAxes, fontsize=11)\n ax.view_init(elev=17, azim=-58)\n ax.set_xlim(0, side); ax.set_ylim(0, side); ax.set_zlim(0, 5.2)\n\n bx = fig.add_axes([0.58, 0.08, 0.40, 0.84])\n bx.set_xlim(0, 10); bx.set_ylim(0, 10); bx.axis(\'off\')\n bx.text(-0.2, 9.75, \'(b)\', fontsize=11)\n outer = FancyBboxPatch((0.4, 0.6), 9.2, 8.4, boxstyle=\'round,pad=0.1\', fc=\'#f4f6f9\', ec=GREY, lw=1.0)\n bx.add_patch(outer)\n bx.text(5.0, 8.5, \'gauge-invariant measures on the fine lattice\', ha=\'center\', fontsize=8.5, color=INK)\n ref = FancyBboxPatch((1.0, 4.3), 4.2, 3.4, boxstyle=\'round,pad=0.1\', fc=\'#e6f2ea\', ec=GREEN, lw=1.4)\n bx.add_patch(ref)\n bx.text(3.1, 6.7, \'Haar refinements\', ha=\'center\', fontsize=9, color=GREEN)\n bx.text(3.1, 5.6, r\'S holds\', ha=\'center\', fontsize=9, color=GREEN)\n bx.text(3.1, 4.8, \'at every scale\', ha=\'center\', fontsize=8, color=GREEN)\n wil = FancyBboxPatch((5.6, 1.4), 3.6, 3.0, boxstyle=\'round,pad=0.1\', fc=\'#fbeaea\', ec=RED, lw=1.4)\n bx.add_patch(wil)\n bx.text(7.4, 3.7, r\'Wilson, $\\beta\\neq0$\', ha=\'center\', fontsize=9, color=RED)\n bx.text(7.4, 3.0, \'not a refinement;\', ha=\'center\', fontsize=8, color=RED)\n bx.text(7.4, 2.4, \'S at strong coupling,\', ha=\'center\', fontsize=8, color=RED)\n bx.text(7.4, 1.8, \'open at weak\', ha=\'center\', fontsize=8, color=RED)\n bx.plot([1.6], [2.2], \'o\', color=BLUE, ms=6)\n bx.text(2.0, 2.05, r\'Haar, $\\beta=0$\', fontsize=8.5, color=BLUE)\n bx.annotate(\'\', xy=(2.0, 4.25), xytext=(1.7, 2.5), arrowprops=dict(arrowstyle=\'->\', color=BLUE, lw=1.0))\n save(fig, \'fig_bptower.png\')\n\n\ndef _node(ax, x, y, text, colour, w=1.7, h=0.62, fs=9):\n p = FancyBboxPatch((x - w / 2, y - h / 2), w, h, boxstyle=\'round,pad=0.06\', fc=\'white\', ec=colour, lw=1.3, zorder=3)\n ax.add_patch(p)\n ax.text(x, y, text, ha=\'center\', va=\'center\', fontsize=fs, color=colour, zorder=4)\n\n\ndef _arrow(ax, a, b, colour=INK, cross=False, rad=0.0):\n ar = FancyArrowPatch(a, b, arrowstyle=\'-|>\', mutation_scale=10, color=colour, lw=1.0,\n connectionstyle=\'arc3,rad=%g\' % rad, shrinkA=14, shrinkB=14, zorder=2,\n linestyle=\'--\' if cross else \'-\')\n ax.add_patch(ar)\n if cross:\n m = (np.array(a) + np.array(b)) / 2\n ax.plot([m[0] - 0.13, m[0] + 0.13], [m[1] - 0.13, m[1] + 0.13], color=RED, lw=1.6, zorder=5)\n ax.plot([m[0] - 0.13, m[0] + 0.13], [m[1] + 0.13, m[1] - 0.13], color=RED, lw=1.6, zorder=5)\n\n\ndef fig_limitlogic():\n fig, ax = plt.subplots(figsize=(9.6, 5.6))\n ax.set_xlim(0, 13.2); ax.set_ylim(-0.45, 8.4); ax.axis(\'off\')\n layers = [(0.35, \'packets under the Wilson measure\', \'#fbeaea\'),\n (3.05, \'lattice bounds\', \'#eef3fa\'),\n (5.75, \'Schwinger functions\', \'#e6f2ea\')]\n for y0, lab, col in layers:\n ax.add_patch(Polygon([[0.5, y0], [12.2, y0], [12.9, y0 + 1.75], [1.2, y0 + 1.75]], closed=True,\n fc=col, ec=GREY, lw=0.8, zorder=0))\n if y0 > 5:\n ax.text(12.1, y0 + 0.1, lab, fontsize=8.5, color=\'#555555\', style=\'italic\', ha=\'right\')\n else:\n ax.text(0.75, y0 + 0.1, lab, fontsize=8.5, color=\'#555555\', style=\'italic\')\n yb, ym, yt = 1.15, 3.85, 6.78\n # inputs\n _node(ax, 1.9, yb, \'(SD), (NE)\', RED)\n _node(ax, 6.0, yb, r\'(SD$_{\\rm p}$)\', RED, w=1.2)\n _node(ax, 8.4, yb, r\'(SB$_n$), (RI$_n$)\', RED, w=1.9)\n _node(ax, 10.7, yb, r\'(MC), (O$_{\\rm s}$)\', RED, w=1.8)\n # lattice bounds\n _node(ax, 2.2, ym, r\'(M$_{\\rm s}$)\', BLUE, w=1.1)\n _node(ax, 4.0, ym, r\'(RN$_m$)\', BLUE, w=1.2)\n _node(ax, 6.0, ym, r\'(G$_{\\rm s}$)\', BLUE, w=1.1)\n _node(ax, 8.4, ym, r\'(W$_{\\rm s}$)\', BLUE, w=1.1)\n _node(ax, 10.7, ym, r\'(U$_{\\rm s}$)\', BLUE, w=1.1)\n # limit\n _node(ax, 2.6, yt, \'separated limits:\\nRP, gap, clustering\', GREEN, w=2.6, h=0.95, fs=8.5)\n _node(ax, 6.0, yt, \'tempered,\\nOS axioms\', GREEN, w=1.9, h=0.95, fs=8.5)\n _node(ax, 9.6, yt, \'convergent,\\nO(4)-invariant\', GREEN, w=2.2, h=0.95, fs=8.5)\n # proved implications\n _arrow(ax, (1.9, yb), (2.2, ym), GREEN)\n ax.text(1.95, 2.45, \'$n=2$;\\nevery $n$ with (GD)\', fontsize=8, color=GREEN, ha=\'right\')\n _arrow(ax, (6.0, yb), (6.0, ym), GREEN)\n ax.text(6.12, 2.45, \'$n=2$;\\nevery $n$ with (GD)\', fontsize=8, color=GREEN)\n _arrow(ax, (8.4, yb), (8.4, ym), GREEN)\n _arrow(ax, (10.7, yb), (10.7, ym), GREEN)\n ax.annotate(\'\', xy=(3.45, ym), xytext=(2.75, ym), arrowprops=dict(arrowstyle=\'<|-|>\', color=GREEN, lw=1.0))\n ax.annotate(\'\', xy=(5.45, ym), xytext=(4.6, ym), arrowprops=dict(arrowstyle=\'<|-|>\', color=GREEN, lw=1.0))\n _arrow(ax, (2.2, ym), (2.6, yt - 0.2), GREEN)\n _arrow(ax, (6.0, ym), (6.0, yt - 0.2), GREEN)\n _arrow(ax, (8.4, ym), (9.3, yt - 0.2), GREEN)\n _arrow(ax, (10.7, ym), (9.75, yt - 0.2), GREEN)\n # obstructions\n _arrow(ax, (1.9, yb), (4.0, ym), INK, cross=True, rad=0.05)\n ax.text(3.25, 2.05, r\'$m\\geq2$\', fontsize=8, color=RED)\n _arrow(ax, (6.0, ym), (8.4, ym), INK, cross=True)\n ax.text(12.85, 8.05, \'the averaged condition along the tuning is assumed throughout\', fontsize=8, color=\'#555555\', ha=\'right\')\n ax.plot([11.5, 13.0], [0.0, 0.0], color=\'none\')\n ax.text(0.6, -0.35, \'red: open inputs blue: lattice bounds green arrows: proved crossed: fails in examples\',\n fontsize=8, color=\'#444444\')\n save(fig, \'fig_limitlogic.png\')\n\n\nif __name__ == \'__main__\':\n fig_bptower()\n fig_limitlogic()\n', 'make_curvedsharp.py': '"""Figure for Proposition prop:curvedsharp: the ratio of the covariant\nHessian of the plaquette action to half the covariant plaquette form, at the\nfield u of the proposition and the SU(2) background of constant curvature in\nthe plane {0,1}, from the closed forms of its proof. (a) The ratio as a\nsurface over the window side n and kappa (n+1)^2, for the two orientations;\n(b) the section n = 63 with the lower bound of part (i) and the threshold 31\nof part (ii).\nRun from this directory: python3 make_curvedsharp.py. Writes\nfig_curvedsharp.png (flattened, 256 colours)."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom make_figures import save\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, INK = \'#3b6fb6\', \'#c0392b\', \'#222222\'\n\n\ndef ratio(n, K, sig):\n """Hess P(0)[u,u] / (Q^{V0}(u)/2) at kappa (n+1)^2 = K."""\n x = np.pi / (2 * n + 2)\n psi = ((n + 1) / 2) ** 2\n s2 = K / 2 / (n + 1) ** 2\n c2 = 1 - s2\n cot2 = 1 / np.tan(x) ** 2\n sigma = 2 / np.tan(x) - np.sin(2 * x)\n u2 = n * (n + 1) * psi\n q1 = 12 * np.sin(x) ** 2 * u2\n qv = q1 + psi * s2 * (4 * n * (n + 1) * np.cos(2 * x) + 8 * sig * c2 * cot2)\n hess = (qv / 2 - 4 * s2 ** 2 * n * (n + 1) * np.cos(x) ** 2 * psi\n + 2 * sig * s2 * c2 * (sigma ** 2 - 2 * cot2) * psi)\n return hess / (qv / 2)\n\n\nns = np.arange(64, 129, 4)\nKs = np.linspace(0, 40, 41)\nN, KK = np.meshgrid(ns, Ks)\nRp = ratio(N, KK, 1)\nRm = ratio(N, KK, -1)\n\nfig = plt.figure(figsize=(10, 4.2))\nax = fig.add_subplot(1, 2, 1, projection=\'3d\')\nax.plot_surface(N, KK, Rp, color=RED, alpha=0.7, edgecolor=\'#7b241c\', linewidth=0.25)\nax.plot_surface(N, KK, Rm, color=BLUE, alpha=0.6, edgecolor=BLUE, linewidth=0.25)\nax.plot_surface(N, KK, 0 * KK, color=\'#999999\', alpha=0.15, linewidth=0)\nax.set_xlabel(r\'window side $n$\', labelpad=4)\nax.set_ylabel(r\'$\\kappa(n+1)^2$\', labelpad=4)\nax.zaxis.set_rotate_label(False)\nax.set_zlabel(r\'$2\\,\\mathcal{H}P(u,u)/Q^{V_0}(u)$\', labelpad=8, rotation=90)\nax.view_init(elev=20, azim=-50)\nax.set_box_aspect((1.1, 1.2, 0.85))\nax.text2D(0.22, 0.84, r\'$\\varsigma=+1$\', color=RED, fontsize=11, transform=ax.transAxes)\nax.text2D(0.58, 0.33, r\'$\\varsigma=-1$\', color=BLUE, fontsize=11, transform=ax.transAxes)\nax.set_title(\'(a)\', loc=\'left\')\n\nax2 = fig.add_subplot(1, 2, 2)\nn = 63\nK = np.linspace(0, 40, 801)\nax2.plot(K, ratio(n, K, 1), color=RED, lw=1.6, label=r\'$\\varsigma=+1$\')\nax2.plot(K, ratio(n, K, -1), color=BLUE, lw=1.6, label=r\'$\\varsigma=-1$\')\nKb = K[K <= 2]\nax2.plot(Kb, 1 + 0.037 * Kb, color=INK, lw=0.9, ls=\'--\', label=r\'$1+0.037\\,\\kappa(n+1)^2$, part (i)\')\nax2.axhline(0, color=\'#888888\', lw=0.6)\nax2.axvline(31, color=INK, lw=0.6, ls=\':\')\nax2.text(31.6, 0.62, r\'$\\kappa(n+1)^2=31$\', fontsize=9)\nax2.set_xlabel(r\'$\\kappa(n+1)^2$, at $n=63$\')\nax2.set_ylabel(r\'$2\\,\\mathcal{H}P(u,u)/Q^{V_0}(u)$\')\nax2.legend(frameon=False, fontsize=8.5, loc=\'lower left\')\nax2.spines[[\'top\', \'right\']].set_visible(False)\nax2.set_title(\'(b)\', loc=\'left\')\nfig.tight_layout()\nsave(fig, \'fig_curvedsharp.png\')\nprint(\'ratio at n=63, K=31, sigma=-1:\', ratio(63, 31, -1), \' zero crossing:\',\n K[np.argmax(ratio(n, K, -1) < 0)])\n', 'make_cutoff.py': '"""Figure of the cut-off average: the sixteen paths of length two from a block\nof side two, drawn in three of the four dimensions, and, for SU(2), the coarse\nlink produced by one link exp(theta X) at the straight path or at another\ntransverse position. Run from this directory: python3 make_cutoff.py. Writes\nfig_cutoff.png (flattened, 256 colours)."""\nimport itertools\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d.art3d import Line3DCollection\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nGREY, BLUE, RED, INK, GREEN = \'#c9c9c9\', \'#3b6fb6\', \'#c0392b\', \'#222222\', \'#2e8b57\'\n\n\ndef paths(ax):\n segs = []\n for x, y, z in itertools.product(range(4), range(2), range(2)):\n for d in range(3):\n q = np.array([x, y, z]) + np.eye(3, dtype=int)[d]\n if q[0] < 4 and q[1] < 2 and q[2] < 2:\n segs.append([(x, y, z), tuple(q)])\n ax.add_collection3d(Line3DCollection(segs, colors=GREY, linewidths=0.6))\n tree = [[(0, 0, 0), (0, 1, 0)], [(0, 0, 0), (0, 0, 1)], [(0, 1, 0), (0, 1, 1)],\n [(0, 0, 0), (1, 0, 0)], [(1, 0, 0), (1, 1, 0)], [(1, 0, 0), (1, 0, 1)], [(1, 1, 0), (1, 1, 1)],\n [(0, 0, 1), (0, 1, 1)]]\n tr = tree[:3] + tree[4:7]\n tr = tr + [[(p[0] + 2,) + p[1:], (q[0] + 2,) + q[1:]] for p, q in tr]\n ax.add_collection3d(Line3DCollection(tr, colors=GREEN, linewidths=1.6, linestyles=(0, (2, 1.5))))\n for o, a1, a2 in itertools.product(range(2), range(2), range(2)):\n h = 0.07 * (1 if o else -1)\n p = [(o, a1, a2 + h), (o + 2, a1, a2 + h)]\n if (o, a1, a2) == (0, 0, 0):\n ax.plot(*zip(*p), color=INK, lw=2.8)\n else:\n ax.plot(*zip(*p), color=BLUE, lw=1.5)\n for c in [(0, 0, 0), (2, 0, 0)]:\n ax.scatter(*c, color=INK, s=26, depthshade=False)\n ax.text(-0.35, -0.05, -0.32, r\'$2y$\', color=INK)\n ax.text(1.65, -0.1, -0.42, r\'$2y+2e_\\mu$\', color=INK)\n ax.text(0.0, 0.0, 1.25, r\'$B(y)$\', color=INK)\n ax.text(2.6, 0.0, 1.5, r\'$B(y+e_\\mu)$\', color=INK)\n ax.text(3.25, 1.0, 0.95, r\'$P_x$\', color=BLUE)\n ax.text(0.75, -0.05, -0.32, r\'$V^{\\rm p}$\', color=INK)\n ax.view_init(elev=24, azim=-62)\n ax.set_xlim(0, 3); ax.set_ylim(0, 1.6); ax.set_zlim(0, 1.6)\n clean3d(ax); ax.set_box_aspect((2.1, 1, 1))\n\n\ndef chi(t):\n return np.clip(2 - 2 * t, 0, 1)\n\n\ndef response(ax):\n th = np.linspace(0, 1.2, 1200)\n dl = 2 * np.sqrt(2) * np.sin(th / 2) # delta(e^{theta X}, I), rho = 1\n c = chi(dl)\n ax.axvspan(0, 2 * np.arcsin(0.5 / (2 * np.sqrt(2))), color=\'#eef3fa\', lw=0)\n ax.axvspan(2 * np.arcsin(0.5 / (2 * np.sqrt(2))), 2 * np.arcsin(1 / (2 * np.sqrt(2))), color=\'#f6f6f6\', lw=0)\n ax.plot(th, th, color=GREY, lw=1.0, ls=(0, (3, 2)))\n ax.plot(th, th / 8, color=GREY, lw=1.0, ls=(0, (3, 2)))\n ax.plot(th, th - 7 * c * th / 8, color=INK, lw=2.0)\n ax.plot(th, c * th / 8, color=BLUE, lw=2.0)\n ax.text(0.58, 1.0, \'link on the path\', color=INK, fontsize=9)\n ax.text(0.76, 0.06, \'link elsewhere\', color=BLUE, fontsize=9)\n ax.text(0.02, 1.08, r\'$\\chi=1$\', color=INK, fontsize=9)\n ax.text(0.39, 1.08, r\'$0<\\chi<1$\', color=INK, fontsize=9)\n ax.text(1.03, 0.2, r\'$\\theta/8$\', color=\'#888888\', fontsize=9)\n ax.set_xlabel(r\'angle $\\theta$ of the link\')\n ax.set_ylabel(r\'angle of $V^\\sharp$\')\n ax.set_xlim(0, 1.2); ax.set_ylim(0, 1.2)\n for sp in [\'top\', \'right\']: ax.spines[sp].set_visible(False)\n\n\nfig = plt.figure(figsize=(7.2, 3.0))\nax1 = fig.add_axes([0.0, 0.0, 0.56, 1.0], projection=\'3d\'); ax1.computed_zorder = False\npaths(ax1)\nax2 = fig.add_axes([0.65, 0.16, 0.33, 0.78])\nresponse(ax2)\nfig.text(0.02, 0.92, \'(a)\'); fig.text(0.56, 0.92, \'(b)\')\nsave(fig, \'fig_cutoff.png\')\n', 'make_fibre.py': '"""Figure for the fibre route to the coarsest condition (ssec:bpfibre).\n\nfig_bpfibre: (a) the fibre law of one step of the straight-path map with\nblocks of side b = 4, drawn in a plane. The coarse data fix the marks (red);\nthe other links of the paths are fixed to I (black) and the links off the\npaths (grey) are integrated. In the Gaussian model the minimiser carries a\ncurrent K Theta that vanishes off the paths, is constant along each path\nwith the value (Gamma v)_e and is conserved at each block corner\n(Proposition prop:bpfibgauss (ii)). (b) the proved bounds\n1/b^2 <= Gamma_ee <= 6/b and the lower bound 2/b^2 on the row sums gamma_b\n(Propositions prop:bpfibgauss, prop:bpfibbloch), against the decay\ngamma_b = O(1/b) that condition (G) asks for, drawn with an arbitrary\nconstant. (c) the lower bound 4 beta delta^2/(pi^2 b^2) on the action of\nthe background that coarse data of SU(2) force on the square of a coarse\nplaquette, for delta = sqrt(2) pi, b = 2^k, along the illustrative tuning\nbeta_k = 2 + (11/(3 pi^2)) k log 2 (Proposition prop:bpfibrough): it tends\nto zero, so it obstructs nothing.\n\nRun from this directory: python3 make_fibre.py."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom matplotlib.patches import FancyArrowPatch\nfrom make_figures import save\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY, GOLD = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\', \'#d4a017\'\n\n\ndef tuning(k, beta0=2.0):\n return beta0 + 11 / (3 * np.pi ** 2) * k * np.log(2)\n\n\ndef fig_bpfibre():\n fig = plt.figure(figsize=(10.0, 3.6))\n ax = fig.add_axes([0.0, 0.05, 0.36, 0.88])\n b, nb = 4, 2\n n = b * nb\n for i in range(n + 1):\n ax.plot([0, n], [i, i], color=GREY, lw=0.5, zorder=1)\n ax.plot([i, i], [0, n], color=GREY, lw=0.5, zorder=1)\n for yx in range(nb + 1):\n for yy in range(nb + 1):\n x0, y0 = b * yx, b * yy\n if yx < nb:\n ax.plot([x0, x0 + b], [y0, y0], color=INK, lw=1.8, zorder=2)\n ax.plot([x0 + b // 2, x0 + b // 2 + 1], [y0, y0], color=RED, lw=3.4, zorder=3, solid_capstyle=\'butt\')\n if yy < nb:\n ax.plot([x0, x0], [y0, y0 + b], color=INK, lw=1.8, zorder=2)\n ax.plot([x0, x0], [y0 + b // 2, y0 + b // 2 + 1], color=RED, lw=3.4, zorder=3, solid_capstyle=\'butt\')\n # current through the corner (4,4)\n cx, cy = 4, 4\n arrows = [((0.6, 4), (3.4, 4)), ((4.6, 4), (7.4, 4)), ((4, 0.6), (4, 3.4)), ((4, 4.6), (4, 7.4))]\n for p, q in arrows:\n off = 0.32\n if p[1] == q[1]:\n p2, q2 = (p[0], p[1] + off), (q[0], q[1] + off)\n else:\n p2, q2 = (p[0] - off, p[1]), (q[0] - off, q[1])\n ax.add_patch(FancyArrowPatch(p2, q2, arrowstyle=\'-|>\', mutation_scale=9, color=BLUE, lw=1.3, zorder=4))\n ax.plot([cx], [cy], \'o\', color=GOLD, ms=7, zorder=5, mec=INK, mew=0.6)\n ax.text(1.0, 4.55, r\'$(\\Gamma v)_{e}$\', color=BLUE, fontsize=9)\n ax.text(5.1, 4.55, r\'$(\\Gamma v)_{e^\\prime}$\', color=BLUE, fontsize=9)\n ax.text(4.25, 2.2, r\'$\\sum_\\nu=0$\', color=GOLD, fontsize=9.5)\n ax.text(-0.3, -0.9, \'marks (red): coarse data; black: fixed to $I$; grey: integrated\', fontsize=7.6)\n ax.set_xlim(-0.6, n + 0.6); ax.set_ylim(-1.3, n + 0.9); ax.set_aspect(\'equal\'); ax.axis(\'off\')\n ax.text(-0.5, n + 0.4, \'(a)\', fontsize=11)\n\n bx = fig.add_axes([0.42, 0.17, 0.25, 0.70])\n bb = np.logspace(np.log10(3), np.log10(1024), 200)\n bx.loglog(bb, 6 / bb, color=INK, lw=1.4, label=r\'$6/b\\geq\\Gamma_{ee}$\')\n bx.loglog(bb, 1 / bb ** 2, color=INK, lw=1.4, ls=\'--\', label=r\'$1/b^2\\leq\\Gamma_{ee}$\')\n bx.loglog(bb, 2 / bb ** 2, color=BLUE, lw=1.3, label=r\'$2/b^2\\leq\\gamma_b$\')\n bx.loglog(bb, 20 / bb, color=RED, lw=1.0, ls=\':\', label=r\'(G): $\\gamma_b=O(1/b)$\')\n bx.set_xlabel(r\'$b$\')\n bx.set_title(r\'(b) the effective form, Gaussian model\', fontsize=10, loc=\'left\')\n bx.legend(fontsize=7.5, frameon=False, loc=\'lower left\')\n\n cx_ = fig.add_axes([0.745, 0.17, 0.235, 0.70])\n ks = np.arange(1, 13)\n D2 = 2 * np.pi ** 2\n bound = 4 * tuning(ks) * D2 / (np.pi ** 2 * 4.0 ** ks)\n cx_.semilogy(ks, bound, \'o-\', color=BLUE, lw=1.3, ms=3.5)\n cx_.set_xticks([2, 4, 6, 8, 10, 12]); cx_.set_xlabel(r\'$k$ (blocks of side $2^k$)\')\n cx_.set_title(r\'(c) forced action, $\\mathrm{SU}(2)$\', fontsize=10, loc=\'left\')\n save(fig, \'fig_bpfibre.png\')\n\n\nif __name__ == \'__main__\':\n fig_bpfibre()\n', 'make_figures.py': '"""Figures of the forest-gauge paper. Run from this directory: python3 make_figures.py.\nReads the certified boxes in ../../gauge-fixed/checks/su3/deg2/r3_2/cover_boxes.txt and the face\nvalues in ../../gauge-fixed/checks/su3/deg2/face2.txt. Writes flattened 256-colour PNG files."""\nimport os, itertools\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d.art3d import Line3DCollection\nfrom PIL import Image\n\nHERE = os.path.dirname(os.path.abspath(__file__))\nDEG2 = os.path.join(HERE, \'..\', \'..\', \'gauge-fixed\', \'checks\', \'su3\', \'deg2\')\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nTABLE = [0, 0, 2, 3, 3, 1, 2, 1, 1, 2, 1, 3, 3, 2, 0, 0]\nsigma = lambda x: TABLE[(x[0] % 2) + 2 * (x[1] % 2) + 4 * (x[2] % 2) + 8 * (x[3] % 2)]\n\ndef save(fig, name, width_px=1600):\n path = os.path.join(HERE, name)\n w_in = fig.get_size_inches()[0]\n fig.savefig(path, dpi=width_px / w_in, facecolor=\'white\')\n plt.close(fig)\n im = Image.open(path).convert(\'RGBA\')\n bg = Image.new(\'RGBA\', im.size, (255, 255, 255, 255))\n bg.alpha_composite(im)\n bg.convert(\'RGB\').quantize(colors=256, method=Image.Quantize.MEDIANCUT, dither=Image.Dither.NONE).save(path, optimize=True)\n print(\'wrote\', name, Image.open(path).size)\n\ndef clean3d(ax):\n ax.set_axis_off()\n ax.set_box_aspect((1, 1, 0.9))\n\ndef fig_linefield():\n fig = plt.figure(figsize=(7.2, 3.4))\n ax = fig.add_subplot(1, 2, 1, projection=\'3d\'); clean3d(ax)\n ax.computed_zorder = False\n n = 3\n segs = []\n for x0, x1, x2 in itertools.product(range(n), repeat=3):\n for m in range(3):\n y = [x0, x1, x2]; y[m] += 1\n if y[m] < n:\n segs.append([(x0, x1, x2), tuple(y)])\n ax.add_collection3d(Line3DCollection(segs, colors=\'0.78\', linewidths=0.6, zorder=1))\n for x0, x1, x2 in itertools.product(range(n), repeat=3):\n s = sigma((x0, x1, x2, 0))\n if s < 3:\n e = np.zeros(3); e[s] = 1.0; p0 = np.array([x0, x1, x2], float)\n ax.plot(*zip(p0, p0 + 1.0 * e), color=\'#c0392b\', linewidth=3.0, solid_capstyle=\'butt\', zorder=5)\n ax.scatter(*(p0 + 0.62 * e), s=16, marker=\'o\', c=\'#c0392b\', depthshade=False, zorder=6)\n else:\n ax.scatter([x0], [x1], [x2], s=34, marker=\'o\', facecolors=\'#e67e22\', edgecolors=\'#7e3f0a\', linewidths=0.6, depthshade=False, zorder=6)\n ax.scatter(*np.array(list(itertools.product(range(n), repeat=3))).T, s=5, c=\'k\', depthshade=False, zorder=7)\n ax.set_xlim(0, n - 0.4); ax.set_ylim(0, n - 0.4); ax.set_zlim(0, n - 0.4)\n ax.view_init(elev=22, azim=-58)\n ax.text2D(0.02, 0.95, \'(a) the line field in the slice $x_3=0$\', transform=ax.transAxes)\n ax = fig.add_subplot(1, 2, 2, projection=\'3d\'); clean3d(ax)\n P = np.array([(0, 0, 0), (1.6, 0, 0), (1.6, 0, 1.6), (0, 0, 1.6)])\n edges = [(0, 1, \'#c0392b\', r\'$e_1$ (fixed)\'), (1, 2, \'#2e6fb7\', r\'$e_2$: $\\frac{21}{10}$\'),\n (3, 2, \'#1e8449\', r\'$e_3$: $\\frac{5}{4}$\'), (0, 3, \'#2e6fb7\', r\'$e_4$: $\\frac{21}{10}$\')]\n for i, j, c, lab in edges:\n a, b = P[i], P[j]\n ax.plot(*zip(a, b), color=c, linewidth=3.2)\n mid = (a + b) / 2; off = mid - P.mean(0)\n ax.text(*(mid + 0.38 * off / np.linalg.norm(off)), lab, color=c, ha=\'center\', va=\'center\', fontsize=10)\n for k in (2, 3):\n ax.scatter(*P[k], s=60, c=\'#8e44ad\', depthshade=False)\n ax.plot([0.25, 1.35, 1.35, 0.25, 0.25], [0, 0, 0, 0, 0], [0.25, 0.25, 1.35, 1.35, 0.25], color=\'0.6\', linewidth=0.6, linestyle=\':\')\n ax.text(0.8, 0, 0.8, r\'$p$\', ha=\'center\', va=\'center\', fontsize=13)\n ax.scatter(*P.T, s=12, c=\'k\', depthshade=False)\n ax.set_xlim(-0.4, 2.0); ax.set_ylim(-1, 1); ax.set_zlim(-0.4, 2.0)\n ax.view_init(elev=18, azim=-70)\n ax.text2D(0.02, 0.95, \'(b) one plaquette in the gauge\', transform=ax.transAxes)\n fig.subplots_adjust(left=0, right=1, bottom=0, top=1, wspace=0)\n save(fig, \'fig_linefield.png\')\n\ndef fig_ranges():\n from matplotlib.patches import Patch\n fig = plt.figure(figsize=(7.2, 4.4))\n ax = fig.add_axes([-0.06, 0.2, 1.1, 0.86], projection=\'3d\')\n meth = {\'SZZ\': (\'ungauged curvature (Shen, Zhu, Zhu)\', \'#d5d8dc\'),\n \'curv\': (\'ungauged curvature, sharp\', \'#95a5a6\'),\n \'quarter\': (\'ungauged Dobrushin, sharp quarter\', \'#566573\'),\n \'fcurv\': (\'forest gauge, curvature\', \'#2e6fb7\'),\n \'fdob\': (\'forest gauge, single-link Dobrushin\', \'#c0392b\'),\n \'fblock\': (\'forest gauge, plaquette blocks\', \'#e67e22\')}\n col = {k: i for i, k in enumerate(meth)}\n rows = [(\'SU(2)\', [(\'curv\', 4 / 32, \'1/8\'), (\'quarter\', 2 / 9, \'2/9\'), (\'fdob\', 1 / 3, \'1/3\'), (\'fblock\', 0.348, \'0.348\')]),\n (\'SU(3)\', [(\'SZZ\', 9 / 48, \'3/16\'), (\'curv\', 9 / 32, \'9/32\'), (\'fcurv\', 9 / 29, \'9/29\'), (\'fdob\', 0.515, \'0.515\'), (\'fblock\', 0.52, \'0.52\')])]\n ax.computed_zorder = False\n for yi, (name, items) in enumerate(rows):\n y0 = 1.5 * yi\n for key, v, lab in items:\n x0 = 1.15 * col[key]\n z = 10 + 10 * (1 - yi) + col[key]\n ax.bar3d(x0, y0, 0, 0.6, 0.6, v, color=meth[key][1], alpha=1.0, shade=True, edgecolor=\'0.3\', linewidth=0.3, zorder=z).set_clip_on(False)\n ax.text(x0 + 0.3, y0 + 0.3, v + 0.02, f\'${lab}$\', ha=\'center\', va=\'bottom\', fontsize=9, zorder=100,\n bbox=dict(boxstyle=\'round,pad=0.1\', fc=\'white\', ec=\'none\', alpha=0.85))\n ax.text(-0.35, y0 + 0.3, 0, name, fontsize=11, ha=\'right\', va=\'center\', zorder=100)\n ax.set_xticks([]); ax.set_yticks([]); ax.set_zlim(0, 0.8); ax.set_zticks([0, 0.25, 0.5, 0.75])\n ax.tick_params(labelsize=8)\n ax.set_xlim(-0.2, 6.6); ax.set_ylim(-0.2, 2.3)\n ax.set_box_aspect((2.8, 1.1, 1.0), zoom=1.25)\n ax.view_init(elev=22, azim=-62); ax.set_proj_type(\'ortho\')\n ax.xaxis.pane.fill = ax.yaxis.pane.fill = False\n ax.set_zlabel(r\'$\\beta_W$\', labelpad=2)\n fig.legend(handles=[Patch(color=c, label=l) for l, c in meth.values()], loc=\'lower center\',\n bbox_to_anchor=(0.5, 0.0), ncol=2, fontsize=8.5, frameon=False)\n save(fig, \'fig_ranges.png\')\n\ndef fig_cover():\n A = np.array([[float(t) for t in l.split()] for l in open(os.path.join(DEG2, \'r3_2\', \'cover_boxes.txt\')) if not l.startswith(\'#\')])\n lo, hi, val = A[:, :4], A[:, 4:8], A[:, 9]\n c = (lo + hi) / 2\n r = 3 / 2\n fig = plt.figure(figsize=(7.2, 3.8))\n ax = fig.add_subplot(1, 2, 1, projection=\'3d\')\n sc = ax.scatter(c[:, 0], c[:, 1], np.hypot(c[:, 2], c[:, 3]), c=val, cmap=\'viridis\', vmin=0.84, vmax=1.0, s=10 * (hi[:, 0] - lo[:, 0]) / (r / 8) + 3, depthshade=False)\n ax.set_xlabel(r\'$a_1$\', labelpad=-6); ax.set_ylabel(r\'$a_2$\', labelpad=-6)\n ax.tick_params(labelsize=7, pad=-2)\n ax.view_init(elev=24, azim=-128)\n ax.set_title(f\'(a) all {len(val)} boxes; height $|z_3|$\', fontsize=10)\n ax = fig.add_subplot(1, 2, 2, projection=\'3d\')\n sel = val > 0.99\n ax.scatter(c[sel, 0], c[sel, 1], c[sel, 2], c=val[sel], cmap=\'viridis\', vmin=0.84, vmax=1.0, s=12, depthshade=False)\n ax.set_xlabel(r\'$a_1$\', labelpad=-6); ax.set_ylabel(r\'$a_2$\', labelpad=-6)\n ax.tick_params(labelsize=7, pad=-2)\n ax.view_init(elev=24, azim=-128)\n ax.set_title(\'(b) bound above 0.99; height $x_3$\', fontsize=10)\n cax = fig.add_axes([0.905, 0.22, 0.016, 0.56])\n cb = fig.colorbar(sc, cax=cax, ticks=[0.84, 0.88, 0.92, 0.96, 1.0])\n cb.set_label(\'certified bound on the box\', fontsize=9); cb.ax.tick_params(labelsize=7)\n fig.subplots_adjust(left=0.05, right=0.87, bottom=0.02, top=0.92, wspace=0.08)\n save(fig, \'fig_cover.png\')\n\ndef fig_face():\n data = {}\n for l in open(os.path.join(DEG2, \'face2.txt\')):\n if not l.startswith(\'r=\'): continue\n a = l.replace(\':\', \' \').split()\n r = float(a[0][2:]); q = float(a[1].split(\'=\')[1])\n v1 = float(a[2].split(\'=\')[1]); v2 = float(a[3].split(\'=\')[1])\n data.setdefault(r, []).append((q, v1, v2))\n fig = plt.figure(figsize=(7.2, 3.6))\n ax = fig.add_subplot(1, 1, 1, projection=\'3d\')\n cols = {1.44: \'#2e6fb7\', 1.5: \'#1e8449\', 1.54: \'#c0392b\'}\n for r, pts in sorted(data.items()):\n pts = sorted(pts); q = np.array([p[0] for p in pts])\n v1 = np.array([p[1] for p in pts]); v2 = np.array([p[2] for p in pts])\n c = cols.get(r, \'k\')\n ax.plot(q, r + 0 * q, v1, color=c, linewidth=1.4, linestyle=\'--\')\n ax.plot(q, r + 0 * q, v2, color=c, linewidth=2.2, marker=\'o\', markersize=3)\n for qq, vv in zip(q, v2):\n ax.plot([qq, qq], [r, r], [0.90, vv], color=c, linewidth=0.4, alpha=0.5)\n Q, R = np.meshgrid(np.linspace(0.5, 1.0, 2), np.linspace(1.42, 1.56, 2))\n ax.plot_surface(Q, R, 1 + 0 * Q, color=\'0.6\', alpha=0.25)\n ax.set_xlabel(r\'$\\rho/r$\', labelpad=-4); ax.set_ylabel(r\'$r$\', labelpad=-2); ax.set_zlabel(\'bound\', labelpad=2)\n ax.tick_params(labelsize=7, pad=-2); ax.set_zlim(0.90, 1.10)\n ax.set_xticks([0.5, 0.6, 0.7, 0.8, 0.9, 1.0]); ax.set_yticks([1.44, 1.50, 1.54]); ax.set_zticks([0.92, 0.96, 1.0, 1.04, 1.08])\n ax.view_init(elev=16, azim=-62)\n ax.set_box_aspect((2.2, 1.1, 1.0), zoom=1.12)\n from matplotlib.lines import Line2D\n fig.legend(handles=[Line2D([], [], color=\'k\', linewidth=2.2, marker=\'o\', markersize=3, label=\'degree-two corrector\'),\n Line2D([], [], color=\'k\', linewidth=1.4, linestyle=\'--\', label=\'blended corrector\')]\n + [Line2D([], [], color=c, linewidth=2.2, label=f\'$r={r:.2f}$\') for r, c in sorted(cols.items())],\n loc=\'upper left\', bbox_to_anchor=(0.06, 0.97), fontsize=8.5, frameon=False)\n fig.subplots_adjust(left=0, right=1, bottom=0, top=1)\n save(fig, \'fig_face.png\')\n\nGROUPS = [(\'SU(2)\', 2, 1.0), (\'SU(3)\', 3, 1.5), (\'Sp(2)\', 4, 1.5), (\'SO(5)\', 5, 0.75), (\'G$_2$\', 7, 1.0),\n (\'F$_4$\', 26, 0.75), (\'E$_6$\', 27, 1.0), (\'E$_7$\', 56, 0.75), (\'E$_8$\', 248, 0.25)]\n\ndef fig_groups():\n """Gap m_G as a function of beta_W = N^2 beta for nine groups (Theorem thm:groups)."""\n fig = plt.figure(figsize=(7.2, 4.0))\n ax = fig.add_subplot(1, 1, 1, projection=\'3d\')\n cmap = plt.get_cmap(\'viridis\')\n for k, (name, N, kap) in enumerate(GROUPS):\n top = 2 * kap * N / 29 # range of beta_W\n bw = np.geomspace(top * 1e-3, top * (1 - 1e-6), 400)\n u = bw / (N * kap) # N|beta| / kappa_G\n m = np.arccosh(1 + (1 / u - 29 / 2) / 12)\n x = np.log10(bw); y = np.full_like(x, k); c = cmap(k / (len(GROUPS) - 1))\n ax.plot(x, y, m, color=c, linewidth=1.8)\n verts = [list(zip(x, y, m)) + [(x[-1], k, 0), (x[0], k, 0)]]\n from mpl_toolkits.mplot3d.art3d import Poly3DCollection\n ax.add_collection3d(Poly3DCollection(verts, facecolors=[c], alpha=0.28, edgecolors=\'none\'))\n ax.scatter([np.log10(top)], [k], [0], color=c, s=14, depthshade=False)\n ax.set_yticks(range(len(GROUPS))); ax.set_yticklabels([g[0] for g in GROUPS], fontsize=7.5)\n ax.set_xticks([-3, -2, -1, 0]); ax.set_xticklabels([\'$10^{-3}$\', \'$10^{-2}$\', \'$10^{-1}$\', \'$1$\'], fontsize=7.5)\n ax.set_xlabel(r\'$\\beta_W$\', labelpad=0); ax.set_zlabel(r\'gap $m_G$\', labelpad=0)\n ax.tick_params(axis=\'z\', labelsize=7.5)\n ax.set_zlim(0, 6.5)\n ax.view_init(elev=24, azim=-58)\n ax.set_box_aspect((1.7, 1.5, 0.9), zoom=1.1)\n fig.subplots_adjust(left=0, right=1, bottom=0, top=1)\n save(fig, \'fig_groups.png\')\n\ndef fig_cubes():\n """(a) averaged cubes: V (n=4) and translates by 2Z^d, drawn in three dimensions;\n (b) one cube of physical side l at three lattice spacings."""\n from mpl_toolkits.mplot3d.art3d import Poly3DCollection\n fig = plt.figure(figsize=(7.2, 3.5))\n ax = fig.add_subplot(1, 2, 1, projection=\'3d\'); clean3d(ax)\n n, L = 4, 7\n def box(o, s, c, a, lw):\n o = np.array(o, float)\n V = [o + s * np.array(v) for v in itertools.product((0, 1), repeat=3)]\n faces = [[V[0], V[1], V[3], V[2]], [V[4], V[5], V[7], V[6]], [V[0], V[1], V[5], V[4]],\n [V[2], V[3], V[7], V[6]], [V[0], V[2], V[6], V[4]], [V[1], V[3], V[7], V[5]]]\n ax.add_collection3d(Poly3DCollection(faces, facecolors=c, alpha=a, edgecolors=c, linewidths=lw))\n pts = np.array(list(itertools.product(range(L), repeat=3)))\n ax.scatter(*pts.T, s=2, c=\'0.55\', depthshade=False)\n box((0, 0, 0), n - 1, \'#2e6fb7\', 0.10, 1.4)\n box((2, 0, 0), n - 1, \'#e67e22\', 0.06, 0.9)\n box((2, 2, 2), n - 1, \'#1e8449\', 0.06, 0.9)\n j0 = np.array([3.0, 3.0, 4.0])\n ax.plot(*zip(j0, j0 + np.array([1, 0, 0])), color=\'#c0392b\', linewidth=3.2)\n ax.text(*(j0 + np.array([0.6, -0.2, 0.55])), r\'$j$\', color=\'#c0392b\', fontsize=11)\n ax.text(0.2, -0.9, -0.6, r\'$V$\', color=\'#2e6fb7\', fontsize=11)\n ax.text(5.2, -0.9, -0.6, r\'$V+2e_1$\', color=\'#e67e22\', fontsize=9)\n ax.text2D(0.62, 0.86, r\'$V+2(e_1+e_2+e_3)$\', color=\'#1e8449\', fontsize=9, transform=ax.transAxes)\n ax.set_xlim(0, L - 1); ax.set_ylim(0, L - 1); ax.set_zlim(0, L - 1)\n ax.view_init(elev=20, azim=-60)\n ax.text2D(0.0, 0.97, \'(a) averaged cubes, $n=4$\', transform=ax.transAxes)\n ax = fig.add_subplot(1, 2, 2, projection=\'3d\'); clean3d(ax)\n ell = 1.0\n for k, (a, c) in enumerate([(0.25, \'#2e6fb7\'), (0.125, \'#1e8449\'), (0.0625, \'#c0392b\')]):\n z = 1.2 * k\n g = np.arange(0, 1.5 + 1e-9, a)\n segs = [[(x, 0, z), (x, 1.5, z)] for x in g] + [[(0, y, z), (1.5, y, z)] for y in g]\n ax.add_collection3d(Line3DCollection(segs, colors=c, linewidths=0.35, alpha=0.55))\n sq = [(0.25, 0.25, z), (0.25 + ell, 0.25, z), (0.25 + ell, 0.25 + ell, z), (0.25, 0.25 + ell, z)]\n ax.add_collection3d(Poly3DCollection([sq], facecolors=c, alpha=0.18, edgecolors=c, linewidths=1.8))\n lab = (f\'$a/{2**k}$\' if k else \'$a$\') + f\', $n={int(round(ell / a))}$\'\n ax.text(1.62, 0.0, z, lab, color=c, fontsize=9.5)\n ax.plot([0.25, 0.25 + ell], [0.12, 0.12], [-0.05, -0.05], color=\'k\', linewidth=1.0)\n ax.text(0.55, -0.25, -0.35, r\'$\\ell=na$\', fontsize=10)\n ax.set_xlim(0, 1.6); ax.set_ylim(0, 1.6); ax.set_zlim(-0.3, 2.6)\n ax.view_init(elev=18, azim=-62)\n ax.text2D(0.0, 0.97, \'(b) one physical scale\', transform=ax.transAxes)\n fig.subplots_adjust(left=0, right=1, bottom=0, top=1, wspace=0)\n save(fig, \'fig_cubes.png\')\n\nif __name__ == \'__main__\':\n fig_linefield(); fig_ranges(); fig_cover(); fig_face(); fig_groups(); fig_cubes()\n', 'make_induction.py': '"""Figure for Theorem thm:allscales and Proposition prop:scalecount: (a) the\ntori of the scales k = 0, ..., 4 drawn as stacked grids, the statement P_k on\neach, the condition (C) on each step, and the steps whose coupling lies below\nthe first-step large-field threshold lambda = 809300; (b) the lower bound\nlower bound log10 log10 Lambda_k >= log10 log10 48^(6^k) of Theorem\nthm:allscales(iv), against the uniform bound sigma_k <= 0.4865 of (ii).\nRun from this directory: python3 make_induction.py. Writes fig_induction.png."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import proj3d\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\'\n\nfig = plt.figure(figsize=(9.0, 3.9))\nax = fig.add_axes([-0.06, -0.04, 0.6, 1.08], projection=\'3d\')\nclean3d(ax)\nax.set_box_aspect((1, 1, 1.25))\nax.computed_zorder = False\nK = 5\nfor k in range(K):\n z = 1.15 * k\n n = 16 // 2 ** k\n s = np.linspace(-2, 2, n + 1)\n col = RED if k >= 3 else BLUE\n face = \'#f6d5d0\' if k >= 3 else \'#d6e3f5\'\n X, Y = np.meshgrid([-2, 2], [-2, 2])\n ax.plot_surface(X, Y, z + 0 * X, color=face, alpha=0.55, shade=False, zorder=2 * k)\n for v in s:\n ax.plot([v, v], [-2, 2], [z, z], color=col, lw=0.45, alpha=0.8, zorder=2 * k + 1)\n ax.plot([-2, 2], [v, v], [z, z], color=col, lw=0.45, alpha=0.8, zorder=2 * k + 1)\n if k < K - 1:\n ax.quiver(0, 0, z + 0.12, 0, 0, 0.9, color=GREEN, lw=1.3, arrow_length_ratio=0.25, zorder=20)\nax.view_init(18, -55)\nax.set_xlim(-2.4, 2.4); ax.set_ylim(-2.4, 2.4); ax.set_zlim(0, 1.15 * (K - 1) + 0.5)\nax.set_title(r\'(a) the scales and the condition (C)\', fontsize=10, y=0.97)\nfig.canvas.draw()\nM = ax.get_proj()\nfor k in range(K):\n z = 1.15 * k\n corners = [proj3d.proj_transform(cx, cy, z, M)[:2] for cx in (-2, 2) for cy in (-2, 2)]\n lx, ly = min(corners)\n ax.annotate(r\'$P_{%d}$\' % k, xy=(lx, ly), xytext=(-16, -4), textcoords=\'offset points\',\n color=INK, fontsize=10, zorder=50)\n if k < K - 1:\n ax_, ay_ = proj3d.proj_transform(0, 0, z + 0.55, M)[:2]\n ax.annotate(r\'(C)\', xy=(ax_, ay_), xytext=(6, -3), textcoords=\'offset points\',\n color=GREEN, fontsize=9, zorder=50)\nfig.text(0.01, 0.1, r\'blue: $\\lambda_k\\geq809300$\', color=BLUE, fontsize=9)\nfig.text(0.01, 0.05, r\'red: $\\lambda_k<809300$\', color=RED, fontsize=9)\n\nbx = fig.add_axes([0.6, 0.17, 0.37, 0.7])\nk = np.arange(0, 5)\nloglogL = np.log10(np.log10(48.0)) + k * np.log10(6.0)\nbx.plot(k, loglogL, \'o-\', color=RED, lw=1.4, ms=4, label=r\'$\\log_{10}\\log_{10}48^{6^k}\\leq\\log_{10}\\log_{10}\\Lambda_k$\')\nbx.axhline(0.4865, color=GREEN, lw=1.2, ls=\'--\')\nbx.text(2.6, 0.6, r\'$\\sigma_k\\leq0.4865$ for all $k$\', color=GREEN, fontsize=9, zorder=50)\nbx.set_xlabel(r\'scale $k$\')\nbx.set_xticks(k)\nbx.spines[[\'top\', \'right\']].set_visible(False)\nbx.legend(frameon=False, fontsize=9, loc=\'upper left\')\nbx.set_title(r\'(b) $\\sigma_k$ stays bounded, $\\Lambda_k$ does not\', fontsize=10)\nsave(fig, \'fig_induction.png\')\n', 'make_largefields.py': '"""Figure of the large fields under the SU(2) Wilson measure: (a) a schematic\nplane of the lattice with clusters of bad unit cubes and the coarse links on\nwhich the cut-off average can be active, all within distance two of a bad\ncube; (b) the frustrated exterior of a link e, one staple at I and five at -I;\n(c) the defect weight q_rho(beta_W) of Theorem "defects" for three values of\nrho, with the level at which the cluster bound 6400 q <= 1/2 starts. Run from\nthis directory: python3 make_largefields.py. Writes fig_largefields.png."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom matplotlib.patches import Rectangle, FancyArrowPatch\nfrom make_figures import save\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nGREY, BLUE, RED, ORANGE, GREEN, INK = \'#c9c9c9\', \'#3b6fb6\', \'#c0392b\', \'#e67e22\', \'#2e8b57\', \'#222222\'\nC0 = 0.5 + 2 / 3 * np.log(24 * np.pi ** 3)\n\n\ndef plane(ax):\n n = 24\n for i in range(n + 1):\n ax.plot([i, i], [0, n], color=GREY, lw=0.35)\n ax.plot([0, n], [i, i], color=GREY, lw=0.35)\n bad = [(3, 4), (4, 4), (4, 5), (15, 6), (11, 15), (12, 15), (12, 16), (19, 19), (6, 18)]\n active = set()\n for (x, y) in bad:\n for mu in range(2):\n for yy in range(0, n, 2):\n for xx in range(0, n, 2):\n tx, ty = x - xx, y - yy\n t, w = (tx, ty) if mu == 0 else (ty, tx)\n if 0 <= t <= 2 and 0 <= w <= 1:\n active.add((xx, yy, mu))\n for (xx, yy, mu) in active:\n dx, dy = (2, 0) if mu == 0 else (0, 2)\n ax.plot([xx, xx + dx], [yy, yy + dy], color=ORANGE, lw=2.2, solid_capstyle=\'round\', zorder=2)\n for (x, y) in bad:\n ax.add_patch(Rectangle((x, y), 1, 1, fc=RED, ec=RED, alpha=0.85, zorder=3))\n for xx in range(0, n + 1, 2):\n for yy in range(0, n + 1, 2):\n ax.plot(xx, yy, \'.\', color=INK, ms=2.2, zorder=4)\n ax.set_xlim(-0.5, n + 0.5); ax.set_ylim(-5.6, n + 2.6); ax.set_aspect(\'equal\'); ax.axis(\'off\')\n ax.add_patch(Rectangle((0.5, -2.6), 1, 1, fc=RED, ec=RED))\n ax.text(2.8, -2.45, r\'bad cube $\\mathcal{C}_x$\', fontsize=8)\n ax.plot([0.0, 2.0], [-4.6, -4.6], color=ORANGE, lw=2.2)\n ax.text(2.8, -4.95, r\'coarse link, bad cube in $\\mathcal{Z}_{y,\\mu}$\', fontsize=8)\n\n\ndef frustrated(ax):\n e0, e1 = np.array([0.0, 0.0]), np.array([2.0, 0.0])\n dirs = [np.array([0, 1.4]), np.array([0, -1.4]), np.array([0.85, 0.75]), np.array([-0.85, -0.75]),\n np.array([-0.8, 0.95]), np.array([0.8, -0.95])]\n for k, d in enumerate(dirs):\n c = GREEN if k == 0 else RED\n p = [e0, e0 + d, e1 + d, e1]\n ax.plot([q[0] for q in p], [q[1] for q in p], color=c, lw=1.6 if k else 2.2, alpha=0.95)\n u = d / np.linalg.norm(d)\n far = (e1 if d[0] >= 0 else e0) + d + 0.32 * u + (np.array([0.18, 0]) if d[0] >= 0 else np.array([-0.18, 0]))\n ax.text(far[0], far[1], r\'$I$\' if k == 0 else r\'$-I$\', color=c, ha=\'center\', va=\'center\', fontsize=9)\n ax.plot([0, 2], [0, 0], color=INK, lw=3.2)\n ax.text(1.0, -0.28, r\'$e$\', ha=\'center\', fontsize=11)\n ax.text(1.0, 1.15, r\'$p_0$\', color=GREEN, ha=\'center\', fontsize=10)\n ax.text(1.0, -2.35, r\'staple sum $-4I$: $U_e\\to-I$, $p_0$ bad\', ha=\'center\', fontsize=9)\n ax.set_xlim(-1.6, 3.6); ax.set_ylim(-2.6, 2.1); ax.set_aspect(\'equal\'); ax.axis(\'off\')\n\n\ndef weights(ax):\n b = np.logspace(1, 6.3, 600)\n for rho, c, lab in [(1.0, INK, r\'$\\rho=1$\'), (0.5, BLUE, r\'$\\rho=1/2$\'), (1 / 12, ORANGE, r\'$\\rho=1/12$\')]:\n lq = np.minimum(0.0, 6 * (np.log(b) + C0) - b * rho ** 2 / 16) / np.log(10)\n ax.plot(b, lq, color=c, lw=1.8, label=lab)\n ax.axhline(np.log10(1 / 12800), color=RED, lw=1, ls=(0, (3, 2)))\n ax.text(12, np.log10(1 / 12800) - 1.0, r\'$6400\\,q=1/2$\', color=RED, fontsize=8.5)\n ax.set_xscale(\'log\'); ax.set_ylim(-14, 1)\n ax.set_xlabel(r\'$\\beta_W$\'); ax.set_ylabel(r\'$\\log_{10}q_\\rho(\\beta_W)$\')\n ax.legend(frameon=False, fontsize=8.5, loc=\'lower left\', handlelength=1.4, borderaxespad=0.1)\n for sp in [\'top\', \'right\']: ax.spines[sp].set_visible(False)\n\n\nfig = plt.figure(figsize=(7.2, 2.75))\nax1 = fig.add_axes([0.0, 0.02, 0.31, 0.95]); plane(ax1)\nax2 = fig.add_axes([0.33, 0.06, 0.27, 0.88]); frustrated(ax2)\nax3 = fig.add_axes([0.71, 0.18, 0.28, 0.76]); weights(ax3)\nfig.text(0.01, 0.93, \'(a)\'); fig.text(0.34, 0.93, \'(b)\'); fig.text(0.63, 0.93, \'(c)\')\nsave(fig, \'fig_largefields.png\')\n', 'make_locality.py': '"""Figure of Theorem "effectivelocal": (a) the multiplier K_P of the effective form S_3\nfor the plane P = {1,2}, as a function of the two transverse momenta (theta_3, theta_4) at\ntheta_1 = theta_2 = 0, equal to 1 at the origin; (b) the largest value of the kernel of K_P\nat l1 distance d on the coarse lattice, k = 1, 2, 3, in floating point on a grid of 12^4\nmomenta. Run from this directory: python3 make_locality.py (about four minutes; it imports\nthe functions of strong-coupling/gauge-fixed/checks/blocks/effective_locality.py). Writes\nfig_locality.png."""\nimport os, sys\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom make_figures import save\n\nHERE = os.path.dirname(os.path.abspath(__file__))\nsys.path.insert(0, os.path.join(HERE, \'..\', \'..\', \'gauge-fixed\', \'checks\', \'blocks\'))\nsys.path.insert(0, HERE)\nimport effective_locality as el\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, ORANGE, GREEN, INK = \'#3b6fb6\', \'#c0392b\', \'#e67e22\', \'#2e8b57\', \'#222222\'\n\nfig = plt.figure(figsize=(8.0, 3.3))\nax = fig.add_axes([-0.04, 0.0, 0.56, 1.0], projection=\'3d\')\nax.set_box_aspect((1, 1, 0.8))\nt = np.linspace(-np.pi, np.pi, 41)\nT3, T4 = np.meshgrid(t, t, indexing=\'ij\')\nth = np.stack([0 * T3, 0 * T3, T3, T4], -1).reshape(-1, 4)\nat, Y = el.blocks(th, 3)\nKp = (at[:, 2] * at[:, 3] / Y).real.reshape(T3.shape)\nax.plot_surface(T3, T4, Kp, cmap=\'viridis\', rstride=1, cstride=1, lw=0.1, edgecolor=\'#444444\', alpha=0.95)\nax.scatter([0], [0], [1], color=RED, s=18, depthshade=False)\nax.set_xlabel(r\'$\\theta_3$\', labelpad=-6)\nax.set_ylabel(r\'$\\theta_4$\', labelpad=-6)\nax.set_zlabel(r\'$K_P$\', labelpad=-4)\nax.set_xticks([-3, 0, 3]); ax.set_yticks([-3, 0, 3])\nax.tick_params(pad=-2, labelsize=8)\nax.view_init(24, -58)\nax.set_title(r\'(a) $K_P$, $P=\\{1,2\\}$, $k=3$\', fontsize=10, y=0.97)\n\nax2 = fig.add_axes([0.62, 0.17, 0.36, 0.7])\nN = 12\njs = np.arange(N) * 2 * np.pi / N\nX = np.stack(np.meshgrid(js, js, js, js, indexing=\'ij\'), -1).reshape(-1, 4)\nrr = np.indices((N,) * 4)\nrr = np.minimum(rr, N - rr).sum(0)\nfor k, col in zip((1, 2, 3), (GREEN, BLUE, ORANGE)):\n at, Y = el.blocks(X, k)\n KP = (np.prod(at[:, 2:], -1) / Y).real\n Kr = np.fft.ifftn(KP.reshape((N,) * 4)).real\n mag = [np.abs(Kr)[rr == d].max() for d in range(7)]\n ax2.semilogy(range(7), mag, \'o-\', color=col, ms=4, lw=1.4, label=r\'$k=%d$\' % k)\nax2.set_xlabel(r\'$|y|_1$\')\nax2.set_ylabel(r\'$\\max|\\mathcal{K}_P(y)|$\')\nax2.legend(frameon=False, fontsize=9)\nax2.set_title(\'(b) kernel of $K_P$ (floating point)\', fontsize=10)\nax2.spines[\'top\'].set_visible(False); ax2.spines[\'right\'].set_visible(False)\nsave(fig, \'fig_locality.png\')\n', 'make_manyislands.py': '"""Figure of several islands of bad blocks in a window: the islands drawn as\ncolumns over a grid of blocks, the good layers between them, and the pairwise\ncross-ratio bounds Delta_uv of Theorem thm:manyislands; and the size of Delta\nfor two islands against the width w of the good layer between them, with the\nprefactor of Lemma lem:lambdatwo. Run from this directory:\npython3 make_manyislands.py. Writes fig_manyislands.png (flattened, 256\ncolours)."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nGREY, BLUE, RED, GREEN, INK = \'#c9c9c9\', \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\'\n\nISLANDS = {\n \'a\': ([(1, 1), (2, 1), (1, 2)], RED),\n \'b\': ([(12, 11), (13, 11), (13, 12), (12, 12)], RED),\n \'q_1\': ([(7, 3), (8, 3)], BLUE),\n \'q_2\': ([(5, 10), (5, 11), (6, 11)], BLUE),\n \'q_3\': ([(12, 5)], BLUE),\n}\n\n\ndef window(ax):\n n = 15\n for i in range(n):\n for j in range(n):\n ax.bar3d(i, j, 0, 0.92, 0.92, 0.04, color=\'#eef3ea\', edgecolor=\'#d4dccf\', linewidth=0.2, shade=False)\n centres = {}\n for name, (cells, col) in ISLANDS.items():\n for (i, j) in cells:\n ax.bar3d(i, j, 0.04, 0.92, 0.92, 0.3, color=col, alpha=0.9, edgecolor=INK, linewidth=0.3)\n c = np.mean(cells, axis=0) + 0.46\n centres[name] = c\n ax.text(c[0] + 1.6, c[1] - 2.4, 0.05, \'$I_{%s}$\' % name, color=col, fontsize=12, ha=\'center\', zorder=12)\n pairs = [(\'a\', \'b\', RED, r\'$\\Delta_{ab}$\', 2.0), (\'a\', \'q_1\', BLUE, \'\', 1.0), (\'q_1\', \'b\', BLUE, \'\', 1.0),\n (\'a\', \'q_2\', BLUE, \'\', 1.0), (\'q_2\', \'b\', BLUE, \'\', 1.0), (\'q_3\', \'b\', BLUE, \'\', 0.8),\n (\'a\', \'q_3\', BLUE, \'\', 1.0)]\n t = np.linspace(0, 1, 60)\n for u, v, col, lab, h in pairs:\n p, q = centres[u], centres[v]\n x = p[0] + (q[0] - p[0]) * t\n y = p[1] + (q[1] - p[1]) * t\n z = 0.34 + 4 * h * t * (1 - t)\n ax.plot(x, y, z, zorder=10, color=col, lw=1.8 if lab else 0.9, ls=\'-\' if lab else (0, (3, 2)))\n if lab:\n ax.text(x[30], y[30], z[30] + 0.25, lab, color=col, fontsize=12, ha=\'center\')\n ax.text2D(0.02, 0.0, \'good layer: every other block is good\', transform=ax.transAxes, fontsize=8.5,\n color=GREEN)\n ax.text2D(0.02, 0.07, r\'dashed: the couplings $\\Delta_{uq}$ through the other islands\', transform=ax.transAxes,\n fontsize=8.5, color=BLUE)\n ax.view_init(elev=34, azim=-62)\n clean3d(ax)\n ax.set_zlim(0, 2.6)\n ax.set_title(\'(a) islands and their pairwise couplings\', fontsize=10)\n\n\ndef decay(ax):\n aG = 2.5e-4\n w = np.linspace(10, 1.3e5, 600)\n D = 3.25e21 * np.exp(-2 * aG * (w - 10))\n ax.semilogy(w / 1e3, D, color=RED, lw=2, label=r\'$\\Delta(w)$ with the evaluated $\\Lambda_2$\')\n ax.axhline(1, color=INK, lw=0.8, ls=(0, (3, 2)))\n ax.axvline(99.072, color=GREY, lw=1.2)\n ax.text(100.5, 1e12, r\'$w=99072$\', color=INK, fontsize=9)\n ax.text(5, 3, r\'$\\Delta=1$\', color=INK, fontsize=9)\n ax.set_xlabel(r\'width $w$ of the good layer (thousands of blocks)\')\n ax.set_ylabel(r\'cross-ratio bound\')\n ax.set_ylim(1e-8, 1e23)\n ax.set_title(\'(b) the bound for two islands\', fontsize=10)\n ax.legend(frameon=False, fontsize=8.5, loc=\'upper right\')\n\n\nfig = plt.figure(figsize=(10, 4.2))\nax1 = fig.add_subplot(1, 2, 1, projection=\'3d\', computed_zorder=False)\nwindow(ax1)\nax2 = fig.add_subplot(1, 2, 2)\ndecay(ax2)\nfig.tight_layout()\nsave(fig, \'fig_manyislands.png\')\n', 'make_metrics.py': '"""Figure for the metrics across scales (ssec:bpmetrics).\n\nfig_bpmetrics: (a) one column of the conditional-mean reconstruction\nR = A^{-1} P^T (P A^{-1} P^T)^{-1} of the block averages P over blocks of\nside 2 on the periodic 18 x 18 lattice, for A = m^2 - Delta with m^2 = 1/10,\ndrawn as bars over the fine sites: positive on its own block, negative on\nthe ring of neighbouring blocks (Proposition prop:bpnegative). (b) The\nproducts prod_{i 0 and C.min() < 0\n lo, hi = 3, n - 3\n X, Y = np.meshgrid(np.arange(lo, hi), np.arange(lo, hi), indexing=\'ij\')\n Z = C[lo:hi, lo:hi]\n cols = np.where(Z.ravel() >= 0, BLUE, RED)\n ax.bar3d(X.ravel(), Y.ravel(), np.minimum(Z.ravel(), 0), 0.8, 0.8, np.abs(Z.ravel()),\n color=cols, shade=True, alpha=0.95, edgecolor=\'white\', linewidth=0.2)\n ax.set_box_aspect((1, 1, 0.6))\n ax.view_init(elev=28, azim=-55)\n ax.set_xticks([]); ax.set_yticks([])\n ax.set_zlabel(\'entry of $R$\', labelpad=6)\n ax.set_title(\'(a) a column of the conditional mean\', fontsize=10)\n\n ax2 = fig.add_subplot(1, 2, 2)\n k, prod, theta = chain()\n ax2.semilogy(k, prod, \'o-\', color=RED, ms=3.5, label=r\'$\\prod_{i= 1 with 10^4 nw q_kappa(beta) <= 1/2, q = exp(6(log b + C0) - b kappa^2/16)."""\n target = math.log(2e4 * nw)\n lo, hi = 1.0, 1.0\n f = lambda b: b * kappa ** 2 / 16 - 6 * (math.log(b) + C0) - target\n while f(hi) < 0:\n hi *= 2\n for _ in range(200):\n mid = math.sqrt(lo * hi)\n if f(mid) >= 0:\n hi = mid\n else:\n lo = mid\n return hi\n\n\nax2 = fig.add_axes([0.60, 0.17, 0.37, 0.70])\nks = np.logspace(-19, 0, 200)\nax2.plot(ks, [beta_min(k, 81) for k in ks], color=RED, lw=1.6, label=r\'$|W|=81$\')\nax2.axvline(4.84e-18, color=GREEN, ls=\'--\', lw=1.0)\nax2.text(7.5e-18, 1e5, r\'$\\kappa=4.8\\cdot10^{-18}$\', color=GREEN, fontsize=8, rotation=90, va=\'bottom\')\nax2.set_xscale(\'log\'); ax2.set_yscale(\'log\')\nax2.set_xlabel(r\'$\\kappa$\')\nax2.set_ylabel(r\'least $\\beta_W$ with bound $\\leq 1/2$\')\nax2.legend(frameon=False, fontsize=8, loc=\'upper right\')\nax2.spines[\'top\'].set_visible(False); ax2.spines[\'right\'].set_visible(False)\nax2.set_title(r\'(b) the bound $10^4|W|\\,q_\\kappa(\\beta_W)$\', fontsize=10)\nprint(\'least beta at kappa = 4.8e-18, |W| = 81:\', f\'{beta_min(4.8e-18, 81):.3e}\')\nsave(fig, \'fig_offchart.png\')\n', 'make_offchartmass.py': '"""Figure for Theorem thm:offchartmass and Corollary cor:offchartmass: (a) the\nlower bound 1 - exp(-15|W| e^{-10^{-24} beta_W}) on the off-chart mass p, as a\nsurface over beta_W/10^24 and log10|W|; (b) the curve beta_W = 10^24 (4.40 +\nln|W|) above which the bound of Theorem thm:badcross improves on the trivial\none, with the region where the lower bound on p exceeds 1/2.\nRun from this directory: python3 make_offchartmass.py. Writes fig_offchartmass.png."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\'\n\nfig = plt.figure(figsize=(9.0, 3.7))\nax = fig.add_axes([-0.03, 0.0, 0.55, 1.0], projection=\'3d\')\nb = np.linspace(0, 16, 121)\nw = np.linspace(0, 4, 81)\nB, Wl = np.meshgrid(b, w)\nP = 1 - np.exp(-15 * 10 ** Wl * np.exp(-B))\nax.plot_surface(B, Wl, P, cmap=\'RdBu_r\', vmin=-0.2, vmax=1.2, rstride=2, cstride=2,\n lw=0.1, edgecolor=\'#ffffff\', alpha=0.95)\nwl = np.linspace(0, 4, 50)\nline = 4.40 + wl * np.log(10)\nax.plot(line, wl, 1 - np.exp(-15 * 10 ** wl * np.exp(-line)), color=GREEN, lw=2.0, zorder=10)\nax.set_xlabel(r\'$\\beta_W/10^{24}$\', labelpad=2)\nax.set_ylabel(r\'$\\log_{10}|W|$\', labelpad=2)\nax.set_zticks([0, 0.5, 1])\nax.set_zlim(0, 1)\nax.view_init(28, -58)\nax.set_box_aspect((1.2, 1, 0.75))\nax.tick_params(labelsize=8, pad=0)\nax.set_title(r\'(a) lower bound on the off-chart mass $p$\', fontsize=10, y=0.98)\n\nbx = fig.add_axes([0.6, 0.17, 0.37, 0.7])\nhalf = np.log(15 * 10 ** wl / np.log(2))\nbx.fill_between(wl, 0, half, color=\'#f3c9c3\', alpha=0.8, lw=0)\nbx.plot(wl, line, color=GREEN, lw=1.6)\nbx.text(0.15, 1.2, r\'$p>1/2$\', color=RED, fontsize=10)\nbx.text(0.15, 14.4, r\'$\\beta_W=10^{24}(4.40+\\ln|W|)$\', color=GREEN, fontsize=9)\nbx.set_xlabel(r\'$\\log_{10}|W|$\')\nbx.set_ylabel(r\'$\\beta_W/10^{24}$\')\nbx.set_xlim(0, 4); bx.set_ylim(0, 16)\nbx.spines[[\'top\', \'right\']].set_visible(False)\nbx.set_title(r\'(b) where the crossing bound is useful\', fontsize=10)\nsave(fig, \'fig_offchartmass.png\')\n', 'make_pathblocks.py': '"""Figure of the path blocks: two adjacent blocks with the straight path between\ntheir roots, a thin path and the slice of links between them, and the torus of\nthe slice variables with its diagonal loop. Run from this directory:\npython3 make_pathblocks.py. Writes fig_pathblocks.png (flattened, 256 colours)."""\nimport itertools\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d.art3d import Line3DCollection\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nGREY, BLUE, RED, INK = \'#c9c9c9\', \'#3b6fb6\', \'#c0392b\', \'#222222\'\n\n\ndef blocks(ax):\n s = 4\n segs = []\n for x, y, z in itertools.product(range(2 * s), range(s), range(s)):\n for d in range(3):\n e = np.eye(3, dtype=int)[d]\n p, q = np.array([x, y, z]), np.array([x, y, z]) + e\n if q[0] < 2 * s and q[1] < s and q[2] < s:\n segs.append([p, q])\n ax.add_collection3d(Line3DCollection(segs, colors=GREY, linewidths=0.5))\n slice_ = [[(s - 1, y, z), (s, y, z)] for y in range(s) for z in range(s)]\n ax.add_collection3d(Line3DCollection(slice_, colors=BLUE, linewidths=2.0))\n ax.plot([0, s], [0, 0], [0, 0], color=INK, lw=2.6)\n thin = [[(j, 2, 3), (j + 1, 2, 3)] for j in range(1, s, 2)]\n ax.add_collection3d(Line3DCollection(thin, colors=RED, linewidths=3.0))\n ax.plot([0, s - 1], [2, 2], [3, 3], color=RED, lw=0.9, ls=(0, (3, 2)))\n for c in [(0, 0, 0), (s, 0, 0)]:\n ax.scatter(*c, color=INK, s=28, depthshade=False)\n ax.text(-0.6, -0.8, -0.9, r\'$sy$\', color=INK)\n ax.text(s - 0.2, -0.9, -0.9, r\'$s(y+e_\\mu)$\', color=INK)\n ax.text(1.4, -0.6, s + 0.4, r\'$B(y)$\', color=INK)\n ax.text(s + 2.4, -0.6, s + 0.4, r\'$B(y+e_\\mu)$\', color=INK)\n ax.text(s - 1.2, s + 0.6, -1.4, r\'slice $T$\', color=BLUE)\n ax.text(-3.4, 2.0, 3.0, \'thin path\', color=RED)\n ax.view_init(elev=22, azim=-58)\n ax.set_xlim(0, 2 * s - 1); ax.set_ylim(0, s); ax.set_zlim(0, s)\n clean3d(ax); ax.set_box_aspect((2, 1, 1))\n\n\ndef torus(ax):\n t = np.linspace(0, 2 * np.pi, 200)\n ax.plot([0, 2 * np.pi, 2 * np.pi, 0, 0], [0, 0, 2 * np.pi, 2 * np.pi, 0], color=GREY, lw=1)\n ax.plot(t, t, color=INK, lw=2.2)\n ax.plot(t, 0 * t + 0.02, color=BLUE, lw=2.2)\n ax.plot(0 * t + 0.02, t, color=RED, lw=2.2)\n ax.text(3.5, 1.9, \'diagonal,\\ndegree 1\', color=INK, fontsize=9)\n ax.text(3.6, 0.25, r\'$W_1$\', color=BLUE)\n ax.text(0.2, 4.1, r\'$W_2$\', color=RED)\n ax.text(0.25, 6.75, r\'$W_1+W_2+\\cdots=1$\', color=INK)\n ax.set_xlabel(r\'$\\theta_1$\'); ax.set_ylabel(r\'$\\theta_2$\')\n ax.set_xticks([0, np.pi, 2 * np.pi]); ax.set_xticklabels([\'0\', r\'$\\pi$\', r\'$2\\pi$\'])\n ax.set_yticks([0, np.pi, 2 * np.pi]); ax.set_yticklabels([\'0\', r\'$\\pi$\', r\'$2\\pi$\'])\n ax.set_aspect(\'equal\'); ax.set_xlim(-0.3, 2 * np.pi + 0.3); ax.set_ylim(-0.3, 2 * np.pi + 1.0)\n for sp in ax.spines.values(): sp.set_visible(False)\n\n\nfig = plt.figure(figsize=(7.2, 3.0))\nax1 = fig.add_axes([0.0, 0.0, 0.62, 1.0], projection=\'3d\'); ax1.computed_zorder = False\nblocks(ax1)\nax2 = fig.add_axes([0.66, 0.14, 0.32, 0.8])\ntorus(ax2)\nfig.text(0.02, 0.92, \'(a)\'); fig.text(0.63, 0.92, \'(b)\')\nsave(fig, \'fig_pathblocks.png\')\n', 'make_paths.py': '"""Figure for the smoothing along the paths (ssec:bppaths).\n\nfig_bppaths: (a) one step of the straight-path map with blocks of side\nb = 6, drawn in a plane. The strict interiors of the paths (red) lie in no\ncommon plaquette, so given the other fine links (the end links of the paths\nin black and the links off the paths in grey) they are independent one-link\nWilson laws, and each coarse link is a product of b - 2 of them between two\nfixed end links (Lemma lem:bppathint). (b) the multipliers\na_d(B) = I_d(B)/I_1(B) of the one-link law on the irreducible representations\nof dimension d = 2, ..., 6, all below the bound 2B/(2B+3)\n(Lemma lem:bppathmodes). (c) the bounds eps, K^2 and h of\nTheorem thm:bppathmixed for blocks of side 2^k along the illustrative tuning\nbeta_W,k = 2 + (11/(3 pi^2)) k log 2, on a logarithmic scale; the curves are\ncomputed from their closed forms through log10, and h, K^2\nare drawn where eps < 1/2.\n\nRun from this directory: python3 make_paths.py."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom scipy.special import ive\nfrom make_figures import save\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY, GOLD = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\', \'#d4a017\'\n\n\ndef tuning(k, beta0=2.0):\n return beta0 + 11 / (3 * np.pi ** 2) * k * np.log(2)\n\n\ndef log10_bounds(k):\n beta = tuning(k)\n b = 2.0 ** k\n B = 6 * beta\n q = 4 * beta / (4 * beta + 1)\n le = np.log10(48.0) + 2 * np.log10(1 + B) + (b - 4) * np.log10(q)\n eps = 10.0 ** np.maximum(le, -300)\n # valid where eps < 1/2: K = B eps/(1-eps), h = (B^2+B) eps/(1-eps) + K^2\n r = 1 - np.minimum(eps, 0.5)\n lK2 = 2 * (np.log10(B) + le - np.log10(r))\n lh = np.log10((B ** 2 + B) * 10.0 ** np.maximum(le, -300) / r + 10.0 ** np.maximum(lK2, -300))\n lh = np.where(le > -150, lh, np.log10(B ** 2 + B) + le - np.log10(r))\n return le, lK2, lh\n\n\ndef fig_bppaths():\n fig = plt.figure(figsize=(10.0, 3.6))\n ax = fig.add_axes([0.0, 0.05, 0.34, 0.88])\n b, nb = 6, 2\n n = b * nb\n for i in range(n + 1):\n ax.plot([0, n], [i, i], color=GREY, lw=0.5, zorder=1)\n ax.plot([i, i], [0, n], color=GREY, lw=0.5, zorder=1)\n for yx in range(nb + 1):\n for yy in range(nb + 1):\n x0, y0 = b * yx, b * yy\n if yx < nb:\n ax.plot([x0, x0 + 1], [y0, y0], color=INK, lw=2.0, zorder=2, solid_capstyle=\'butt\')\n ax.plot([x0 + b - 1, x0 + b], [y0, y0], color=INK, lw=2.0, zorder=2, solid_capstyle=\'butt\')\n ax.plot([x0 + 1, x0 + b - 1], [y0, y0], color=RED, lw=3.0, zorder=3, solid_capstyle=\'butt\')\n if yy < nb:\n ax.plot([x0, x0], [y0, y0 + 1], color=INK, lw=2.0, zorder=2, solid_capstyle=\'butt\')\n ax.plot([x0, x0], [y0 + b - 1, y0 + b], color=INK, lw=2.0, zorder=2, solid_capstyle=\'butt\')\n ax.plot([x0, x0], [y0 + 1, y0 + b - 1], color=RED, lw=3.0, zorder=3, solid_capstyle=\'butt\')\n for yx in range(nb + 1):\n for yy in range(nb + 1):\n ax.plot([b * yx], [b * yy], \'o\', color=GOLD, ms=4.5, zorder=4, mec=INK, mew=0.5)\n ax.text(-0.3, -0.9, r\'red: interiors $Y_1,\\ldots,Y_{b-2}$; black: end links; grey: off the paths\', fontsize=7.4)\n ax.set_xlim(-0.6, n + 0.6); ax.set_ylim(-1.3, n + 0.9); ax.set_aspect(\'equal\'); ax.axis(\'off\')\n ax.text(-0.5, n + 0.4, \'(a)\', fontsize=11)\n\n bx = fig.add_axes([0.41, 0.17, 0.25, 0.70])\n B = np.linspace(0.01, 40, 400)\n for d, ls in zip(range(2, 7), [\'-\', \'--\', \'-.\', \':\', (0, (5, 1))]):\n bx.plot(B, ive(d, B) / ive(1, B), color=BLUE, lw=1.2, ls=ls, label=r\'$a_{%d}$\' % d)\n bx.plot(B, 2 * B / (2 * B + 3), color=RED, lw=1.0, label=r\'$2B/(2B+3)$\')\n bx.set_xlabel(r\'$B$\'); bx.set_ylim(0, 1.02)\n bx.set_title(r\'(b) multipliers of $f_B$\', fontsize=10, loc=\'left\')\n bx.legend(fontsize=7.5, frameon=False, loc=\'lower right\', ncol=2)\n\n cx = fig.add_axes([0.735, 0.17, 0.245, 0.70])\n ks = np.arange(6, 15)\n le, lK2, lh = log10_bounds(ks)\n cx.plot(ks, le, \'o-\', color=BLUE, lw=1.2, ms=3.2, label=r\'$\\log_{10}\\epsilon$\')\n ok = le < np.log10(0.5)\n cx.plot(ks[ok], lh[ok], \'s--\', color=GREEN, lw=1.0, ms=3.0, label=r\'$\\log_{10}h$\')\n cx.plot(ks[ok], lK2[ok], \'^:\', color=RED, lw=1.0, ms=3.0, label=r\'$\\log_{10}K^2$\')\n cx.axhline(0, color=GREY, lw=0.7)\n cx.set_yscale(\'symlog\', linthresh=10)\n cx.set_xlabel(r\'$k$ (blocks of side $2^k$)\')\n cx.set_title(r\'(c) along the tuning\', fontsize=10, loc=\'left\')\n cx.legend(fontsize=7.5, frameon=False, loc=\'lower left\')\n save(fig, \'fig_bppaths.png\')\n\n\nif __name__ == \'__main__\':\n fig_bppaths()\n', 'make_percolation.py': '"""Figure for Theorem thm:clusterpercolation and Lemma lem:windowclusters:\n(a) a schematic of the hierarchical construction in three of the four\ndimensions: bad blocks (small cubes) grouped into clusters of the first level\ninside boxes of side a_1, and clusters of the first level joined into one of\nthe second level inside a box of side a_2, the joining distance growing like\nlog of the cluster size; (b) a torus with a window Lambda: a cluster of the\ntorus that crosses the boundary of the window is cut into clusters of the\nwindow, which are the units of Lemma lem:windowclusters. Schematic, not to scale.\nRun from this directory: python3 make_percolation.py. Writes fig_percolation.png."""\nimport itertools\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d.art3d import Poly3DCollection\nfrom matplotlib.patches import Rectangle\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\'\nrng = np.random.default_rng(7)\n\n\ndef cube(ax, o, s, color):\n x, y, z = o\n v = np.array(list(itertools.product((x, x + s), (y, y + s), (z, z + s))))\n faces = [[v[i] for i in f] for f in ((0, 1, 3, 2), (4, 5, 7, 6), (0, 1, 5, 4),\n (2, 3, 7, 6), (0, 2, 6, 4), (1, 3, 7, 5))]\n ax.add_collection3d(Poly3DCollection(faces, facecolor=color, edgecolor=\'#ffffff\', lw=0.3, alpha=0.95))\n\n\ndef frame(ax, o, s, color, lw):\n x, y, z = o\n for a, b in itertools.combinations(list(itertools.product((x, x + s), (y, y + s), (z, z + s))), 2):\n if sum(u != w for u, w in zip(a, b)) == 1:\n ax.plot(*zip(a, b), color=color, lw=lw)\n\n\nfig = plt.figure(figsize=(9.0, 3.9))\nax = fig.add_axes([-0.03, 0.08, 0.55, 0.94], projection=\'3d\')\nclean3d(ax)\nA1, A2 = 4.0, 12.0\ncentres = [(1.5, 1.5, 1.5), (7.5, 2.0, 1.8), (4.0, 7.5, 6.0), (8.0, 8.0, 8.0)]\ncols = [BLUE, GREEN, \'#8e44ad\', \'#d68910\']\nfor c, col in zip(centres, cols):\n o = np.array(c) - A1 / 2 + 2\n frame(ax, o, A1, col, 0.8)\n for _ in range(5):\n p = o + rng.integers(0, 3, 3) + 0.2\n cube(ax, p, 0.75, col)\nframe(ax, (0, 0, 0), A2, RED, 1.4)\nfor a, b in zip(centres[:-1], centres[1:]):\n ax.plot(*zip(np.array(a) + 2, np.array(b) + 2), color=RED, lw=1.0, ls=\'--\')\nfig.text(0.03, 0.08, r\'thin boxes: clusters of level 1, side $a_1$\', color=INK, fontsize=9)\nfig.text(0.03, 0.03, r\'red box and dashes: one cluster of level 2, side $a_2$\', color=RED, fontsize=9)\nax.view_init(20, -60)\nax.set_xlim(0, A2); ax.set_ylim(0, A2); ax.set_zlim(0, A2)\nax.set_title(r\'(a) clusters joined across levels\', fontsize=10, y=0.97)\n\nbx = fig.add_axes([0.58, 0.08, 0.4, 0.8])\nbx.set_aspect(\'equal\'); bx.axis(\'off\')\nbx.add_patch(Rectangle((0, 0), 10, 10, fill=False, ec=INK, lw=1.0))\nbx.add_patch(Rectangle((2.5, 2.5), 5, 5, fc=\'#eaf1fb\', ec=BLUE, lw=1.4))\npath = np.array([[0.8, 6.0], [2.0, 6.2], [3.0, 5.6], [4.0, 6.0], [5.0, 5.4], [6.2, 5.8], [7.0, 5.2],\n [8.2, 5.6], [9.2, 5.0]])\nfor (x0, y0), (x1, y1) in zip(path[:-1], path[1:]):\n inside = 2.5 <= (x0 + x1) / 2 <= 7.5\n bx.plot([x0, x1], [y0, y1], color=GREEN if inside else GREY, lw=2.0)\nfor x, y in path:\n inside = 2.5 <= x <= 7.5\n bx.add_patch(Rectangle((x - 0.22, y - 0.22), 0.44, 0.44, fc=GREEN if inside else GREY, ec=\'none\'))\nsmall = [[3.4, 3.9], [3.9, 3.8], [6.4, 4.1]]\nfor x, y in small:\n bx.add_patch(Rectangle((x - 0.22, y - 0.22), 0.44, 0.44, fc=\'#8e44ad\', ec=\'none\'))\nbx.text(2.6, 7.75, r\'window $\\Lambda$\', color=BLUE, fontsize=9)\nbx.text(0.2, 9.3, r\'torus $(\\mathbb{Z}/L\\mathbb{Z})^4$\', color=INK, fontsize=9)\nbx.text(0.15, 4.0, \'a torus\\ncluster\', color=GREY, fontsize=9)\nbx.text(3.0, 6.8, r\'its part in $\\Lambda$\', color=GREEN, fontsize=9)\nbx.text(2.75, 2.85, \'other window clusters\', color=\'#8e44ad\', fontsize=8)\nbx.set_xlim(-0.2, 10.2); bx.set_ylim(-0.2, 10.2)\nbx.set_title(r\'(b) clusters of a window\', fontsize=10)\nsave(fig, \'fig_percolation.png\')\n', 'make_plaqblocks.py': '"""Figure of the plaquette blocks: the block plaquettes in the planes {0,1}\nand {2,3}, with the links of the line field. Run from this directory:\npython3 make_plaqblocks.py. Writes fig_plaqblocks.png (flattened, 256 colours)."""\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom matplotlib.patches import Rectangle\nfrom make_figures import save\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nSHADE, GREY, RED, INK = \'#d6e4f5\', \'#9a9a9a\', \'#c0392b\', \'#222222\'\nROWS = {\'0000\': 0, \'1000\': 0, \'0100\': 2, \'1100\': 3, \'0010\': 3, \'1010\': 1, \'0110\': 2, \'1110\': 1,\n \'0001\': 1, \'1001\': 2, \'0101\': 1, \'1101\': 3, \'0011\': 3, \'1011\': 2, \'0111\': 0, \'1111\': 0}\n\n\ndef sigma(x):\n return ROWS[\'\'.join(str(c % 2) for c in x)]\n\n\ndef panel(ax, mu, nu, fixed):\n n = 4\n for a in range(n):\n for b in range(n):\n if a % 2 == b % 2:\n ax.add_patch(Rectangle((a, b), 1, 1, color=SHADE, lw=0))\n for a in range(n + 1):\n for b in range(n + 1):\n x = [0, 0, 0, 0]; x[mu], x[nu] = a, b\n for d, (da, db) in ((mu, (1, 0)), (nu, (0, 1))):\n if a + da > n or b + db > n:\n continue\n y = list(x)\n for k, v in fixed.items():\n y[k] = v\n red = sigma(y) == d\n ax.plot([a, a + da], [b, b + db], color=RED if red else GREY,\n lw=2.6 if red else 0.9, solid_capstyle=\'round\', zorder=3 if red else 2)\n y = list(x)\n for k, v in fixed.items():\n y[k] = v\n out = sigma(y) not in (mu, nu)\n ax.scatter(a, b, s=22, facecolor=\'white\' if out else INK, edgecolor=INK, lw=0.8, zorder=4)\n ax.set_aspect(\'equal\'); ax.set_xlim(-0.4, n + 0.4); ax.set_ylim(-0.6, n + 0.4)\n ax.set_xticks(range(n + 1)); ax.set_yticks(range(n + 1))\n ax.set_xlabel(r\'$x_%d$\' % mu); ax.set_ylabel(r\'$x_%d$\' % nu)\n for sp in ax.spines.values():\n sp.set_visible(False)\n ax.tick_params(length=0)\n\n\nfig, (a1, a2) = plt.subplots(1, 2, figsize=(7.2, 3.4))\npanel(a1, 0, 1, {2: 0, 3: 0}); a1.set_title(r\'(a) plane $\\{0,1\\}$, $x_2=x_3=0$\', fontsize=10)\npanel(a2, 2, 3, {0: 0, 1: 0}); a2.set_title(r\'(b) plane $\\{2,3\\}$, $x_0=x_1=0$\', fontsize=10)\nfig.subplots_adjust(left=0.06, right=0.99, bottom=0.14, top=0.9, wspace=0.25)\nsave(fig, \'fig_plaqblocks.png\')\n', 'make_projected.py': '"""Figure for Definition def:projavg and Theorem thm:projinverse:\n(a) the projected average on a sphere standing for SU(2): the paths P_x\naround the base path P_{2y}, their projections to the tangent plane (the Lie\nalgebra), the mean A of the projections, and the point P_{2y} exp A;\n(b) the map g -> c exp(-A(g)) contracts with constant 7/8, so its iterates\nconverge to the unique solution G of the equation hat V = c, and hat V moves\ndistances by a factor between 1/8 and 15/8. Schematic, not to scale.\nRun from this directory: python3 make_projected.py. Writes fig_projected.png."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\'\nrng = np.random.default_rng(3)\n\nfig = plt.figure(figsize=(9.0, 4.0))\nax = fig.add_axes([-0.04, 0.02, 0.56, 0.98], projection=\'3d\')\nclean3d(ax)\nax.set_box_aspect((1, 1, 1))\nu, v = np.mgrid[0:2 * np.pi:60j, 0:np.pi:30j]\nax.plot_surface(np.cos(u) * np.sin(v), np.sin(u) * np.sin(v), np.cos(v),\n color=\'#dfe6ee\', alpha=0.25, lw=0, shade=True)\nbase = np.array([0.0, 0.0, 1.0])\n# tangent plane at the base point\ns = np.linspace(-1.0, 1.0, 2)\nX, Y = np.meshgrid(s, s)\nax.plot_surface(X, Y, np.ones_like(X), color=BLUE, alpha=0.12, lw=0)\nax.scatter(*base, color=INK, s=28, depthshade=False)\nax.text(-0.45, -0.25, 1.02, r\'$P_{2y}$\', color=INK, fontsize=11)\npts = []\nfor k in range(7):\n t = rng.uniform(0.55, 0.95); ph = -1.1 + 2.9 * k / 6 + rng.uniform(-0.15, 0.15)\n p = np.array([np.sin(t) * np.cos(ph), np.sin(t) * np.sin(ph), np.cos(t)])\n q = np.array([p[0], p[1], 1.0])\n pts.append(q)\n ax.scatter(*p, color=GREEN, s=14, depthshade=False)\n ax.plot(*zip(p, q), color=GREY, lw=0.8, ls=\':\')\n ax.scatter(*q, color=BLUE, s=10, depthshade=False)\n ax.plot(*zip(base, q), color=BLUE, lw=0.6, alpha=0.6)\nA = np.mean(pts, axis=0)\nax.quiver(*base, *(A - base), color=RED, lw=1.8, arrow_length_ratio=0.25)\nr = np.linalg.norm(A[:2])\ntip = np.array([A[0] / r * np.sin(r), A[1] / r * np.sin(r), np.cos(r)])\nax.scatter(*tip, color=RED, s=30, depthshade=False)\nax.text(*(A + np.array([0.04, 0.04, 0.08])), r\'$A$\', color=RED, fontsize=11)\nax.text(*(tip + np.array([0.55, 0.35, -0.05])), r\'$\\widehat V=P_{2y}e^{A}$\', color=RED, fontsize=11)\nax.text(0.25, -1.05, 0.55, r\'paths $P_x$\', color=GREEN, fontsize=10)\nax.text(-1.0, 0.9, 1.08, r\'tangent space\', color=BLUE, fontsize=10)\nax.view_init(elev=38, azim=-58)\nax.set_xlim(-1, 1); ax.set_ylim(-1, 1); ax.set_zlim(-0.6, 1.2)\nfig.text(0.02, 0.93, \'(a)\', fontsize=11)\n\nbx = fig.add_axes([0.57, 0.14, 0.40, 0.76])\ng = np.array([1.6, 1.2]); G = np.array([0.0, 0.0])\ntraj = [g]\nrot = np.array([[np.cos(0.5), -np.sin(0.5)], [np.sin(0.5), np.cos(0.5)]])\nfor _ in range(12):\n g = 0.875 * rot @ g\n traj.append(g)\ntraj = np.array(traj)\nfor rad in (0.4, 0.8, 1.2, 1.6, 2.0):\n th = np.linspace(0, 2 * np.pi, 200)\n bx.plot(rad * np.cos(th), rad * np.sin(th), color=GREY, lw=0.4, alpha=0.6)\nbx.plot(traj[:, 0], traj[:, 1], color=BLUE, lw=1.0, marker=\'o\', ms=3)\nbx.scatter(*G, color=RED, s=40, zorder=5)\nbx.annotate(r\'$G$\', G, xytext=(-0.45, -0.35), color=RED)\nbx.annotate(r\'$g$\', traj[0], xytext=(traj[0][0] + 0.08, traj[0][1] + 0.08), color=BLUE)\nbx.text(-2.0, 1.75, r\'$g\\mapsto c_k\\,e^{-A(g)}$, constant $\\frac{7}{8}$\', fontsize=9)\nbx.text(-2.0, -2.05, r\'$\\frac{1}{8}\\,d(g,g^\\prime)\\leq d(\\widehat V_k g,\\widehat V_k g^\\prime)\\leq\\frac{15}{8}\\,d(g,g^\\prime)$\', fontsize=9)\nbx.set_aspect(\'equal\'); bx.set_xlim(-2.2, 2.2); bx.set_ylim(-2.3, 2.1); bx.axis(\'off\')\nfig.text(0.56, 0.93, \'(b)\', fontsize=11)\nsave(fig, \'fig_projected.png\')\n', 'make_scalelosses.py': '"""Figure for Proposition prop:scalelosses and Corollary cor:smearedtrial:\n(a) the product of the factors 1 - c_j over the scales between the lattice\nspacing and the separation sigma along the one-loop SU(2) tuning, for losses\nof first order (c_j = c g_j^2) and of second order (c_j = c g_j^4) in the\nrunning coupling, as a surface over the number of scales J and the\nconstant c; (b) the section at c = 0.1, with beta_W = 20 at the scale sigma, with the rate (log 1/a)^(-4c/h).\nRun from this directory: python3 make_scalelosses.py. Writes\nfig_scalelosses.png (flattened, 256 colours)."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom make_figures import save\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, INK = \'#3b6fb6\', \'#c0392b\', \'#222222\'\n\nb = 11 / (3 * np.pi ** 2)\nh = b * np.log(2)\nbeta_sigma = 20.0 # beta_W at the scale sigma\n\n\ndef products(J, c):\n j = np.arange(J + 1)\n beta = beta_sigma + h * (J - j)\n g2 = 4 / beta\n first = np.prod(1 - np.minimum(c * g2, 0.5))\n second = np.prod(1 - np.minimum(c * g2 ** 2, 0.5))\n return first, second\n\n\nJs = np.arange(0, 2001, 50)\ncs = np.linspace(0.02, 0.2, 19)\nF = np.zeros((len(cs), len(Js)))\nS = np.zeros_like(F)\nfor a, c in enumerate(cs):\n for k, J in enumerate(Js):\n F[a, k], S[a, k] = products(J, c)\n\nfig = plt.figure(figsize=(10, 4.2))\nax = fig.add_subplot(1, 2, 1, projection=\'3d\')\nX, Y = np.meshgrid(Js, cs)\nax.plot_surface(X, Y, S, color=BLUE, alpha=0.55, edgecolor=BLUE, linewidth=0.25)\nax.plot_surface(X, Y, F, color=RED, alpha=0.75, edgecolor=\'#7b241c\', linewidth=0.25)\nax.set_xlabel(r\'scales $J=\\log_2(\\sigma/a_k)$\', labelpad=4)\nax.set_ylabel(r\'$c$\', labelpad=2)\nax.zaxis.set_rotate_label(False)\nax.set_zlabel(r\'$\\prod_j(1-c_j)$\', labelpad=6, rotation=90)\nax.set_zlim(0, 1)\nax.view_init(elev=22, azim=-58)\nax.set_box_aspect((1.3, 1, 0.8))\nax.text2D(0.66, 0.74, r\'$c_j=c\\,g_j^4$\', color=BLUE, fontsize=11, transform=ax.transAxes)\nax.text2D(0.66, 0.42, r\'$c_j=c\\,g_j^2$\', color=RED, fontsize=11, transform=ax.transAxes)\nax.set_title(\'(a)\', loc=\'left\')\n\nax2 = fig.add_subplot(1, 2, 2)\nc = 0.1\nJfine = np.arange(0, 2001)\nf = np.array([products(J, c)[0] for J in Jfine])\ns = np.array([products(J, c)[1] for J in Jfine])\nax2.semilogy(Jfine, f, color=RED, lw=1.6, label=r\'first order, $c_j=0.1\\,g_j^2$\')\nax2.semilogy(Jfine, s, color=BLUE, lw=1.6, label=r\'second order, $c_j=0.1\\,g_j^4$\')\nrate = (beta_sigma / (beta_sigma + h * (Jfine + 1))) ** (4 * c / h)\nax2.semilogy(Jfine, rate, color=INK, lw=0.9, ls=\'--\', label=r\'$(\\beta_\\sigma/(\\beta_\\sigma+b\\log(2\\sigma/a_k)))^{4c/h}$\')\nax2.set_xlabel(r\'scales $J=\\log_2(\\sigma/a_k)$\')\nax2.set_ylabel(\'product over the scales\')\nax2.set_ylim(1e-3, 1.5)\nax2.legend(frameon=False, fontsize=8.5, loc=\'lower left\')\nax2.spines[[\'top\', \'right\']].set_visible(False)\nax2.set_title(\'(b)\', loc=\'left\')\nfig.tight_layout()\nsave(fig, \'fig_scalelosses.png\')\n', 'make_scales.py': '"""Figure of the cut-off average across scales on torus-valued fields: a coarse\nplaquette as the mean of the 2x2 fluxes at its offsets (drawn in the plane of\nthe plaquette), and, for the thin-path fields, the coarse energy left by the\nk-fold path map and the bound for the k-fold cut-off average. Run from this\ndirectory: python3 make_scales.py. Writes fig_scales.png (flattened, 256\ncolours)."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom matplotlib.patches import Rectangle\nfrom make_figures import save\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nGREY, BLUE, RED, INK = \'#c9c9c9\', \'#3b6fb6\', \'#c0392b\', \'#222222\'\n\n\ndef squares(ax):\n for i in range(4):\n ax.plot([i, i], [0, 3], color=GREY, lw=0.6)\n ax.plot([0, 3], [i, i], color=GREY, lw=0.6)\n ax.add_patch(Rectangle((0, 0), 2, 2, fill=False, ec=INK, lw=2.4))\n cols = [\'#3b6fb6\', \'#5b8fd6\', \'#2e8b57\', \'#c0392b\']\n for k, (a, b) in enumerate([(0, 0), (1, 0), (0, 1), (1, 1)]):\n ax.add_patch(Rectangle((a + 0.06 * k, b + 0.06 * k), 2, 2, fill=True, fc=cols[k], alpha=0.16,\n ec=cols[k], lw=1.4))\n ax.plot(a, b, \'o\', color=cols[k], ms=4)\n ax.text(3.15, 2.6, \'fine 2x2 squares\\nat the offsets o\', color=BLUE, fontsize=9)\n ax.text(-0.15, -0.35, r\'$2y$\', color=INK, fontsize=10)\n ax.text(0.15, 1.55, \'coarse\\nplaquette\', color=INK, fontsize=8.5)\n ax.text(0.0, -0.75, r\'$\\Theta^\\sharp_P=\\frac{1}{16}\\sum_o F_{2y+o}$\', color=INK, fontsize=10)\n ax.set_xlim(-0.4, 5.2); ax.set_ylim(-1.0, 3.4); ax.set_aspect(\'equal\'); ax.axis(\'off\')\n\n\ndef energies(ax):\n k = np.arange(14, 25)\n s = 2.0 ** k\n ax.semilogy(k, 24 + 0 * k, color=INK, lw=2, label=r\'path map, $Q_k=24$\')\n ax.semilogy(k, 18 * np.pi ** 2 / s ** 2, color=BLUE, lw=2, label=r\'cut-off average, $\\leq18\\pi^2/s^2$\')\n ax.semilogy(k, 24 * s * np.sin(np.pi / (2 * s)) ** 2, color=GREY, lw=1.5, ls=(0, (3, 2)),\n label=r\'fine energy $Q$\')\n ax.set_xlabel(r\'$k$, with $s=2^k$\')\n ax.set_ylabel(\'energy\')\n ax.legend(frameon=False, fontsize=8.5, loc=\'upper right\', bbox_to_anchor=(1.0, 0.9))\n for sp in [\'top\', \'right\']: ax.spines[sp].set_visible(False)\n\n\nfig = plt.figure(figsize=(7.2, 3.0))\nax1 = fig.add_axes([0.0, 0.05, 0.42, 0.9]); squares(ax1)\nax2 = fig.add_axes([0.53, 0.16, 0.45, 0.78]); energies(ax2)\nfig.text(0.02, 0.92, \'(a)\'); fig.text(0.44, 0.92, \'(b)\')\nsave(fig, \'fig_scales.png\')\n', 'make_schematics.py': '"""Schematic figures of the continuum part of the forest-gauge paper.\nRun from this directory: python3 make_schematics.py. Writes flattened 256-colour PNG files."""\nimport os, itertools, math\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d.art3d import Poly3DCollection, Line3DCollection\nfrom scipy.special import ive\nfrom make_figures import save\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nGREEN, BLUE, RED, GREY = \'#1e8449\', \'#2e6fb7\', \'#c0392b\', \'0.55\'\n\n\ndef cuboid(ax, o, s, color, alpha=0.35, lw=0.6, edge=None):\n x, y, z = o; dx, dy, dz = s\n v = np.array([[x, y, z], [x + dx, y, z], [x + dx, y + dy, z], [x, y + dy, z],\n [x, y, z + dz], [x + dx, y, z + dz], [x + dx, y + dy, z + dz], [x, y + dy, z + dz]])\n faces = [[v[i] for i in f] for f in ([0, 1, 2, 3], [4, 5, 6, 7], [0, 1, 5, 4],\n [2, 3, 7, 6], [1, 2, 6, 5], [0, 3, 7, 4])]\n ax.add_collection3d(Poly3DCollection(faces, facecolors=color, edgecolors=edge or color,\n linewidths=lw, alpha=alpha))\n\n\ndef clean(ax, aspect=(1, 1, 0.8)):\n ax.set_axis_off()\n ax.set_box_aspect(aspect)\n\n\ndef fig_logic():\n """Three layers: proved at fixed spacing, proved implications, open inputs."""\n fig = plt.figure(figsize=(7.4, 5.0))\n ax = fig.add_axes([0.0, 0.0, 0.62, 1.0], projection=\'3d\'); clean(ax, (1.6, 1, 1.25))\n ax.computed_zorder = False\n layers = [(0.0, GREEN), (1.6, BLUE), (3.2, RED)]\n for z, c in layers:\n P = [[(-0.3, -0.3, z), (6.3, -0.3, z), (6.3, 2.3, z), (-0.3, 2.3, z)]]\n ax.add_collection3d(Poly3DCollection(P, facecolors=c, alpha=0.06, edgecolors=c, linewidths=0.5))\n for i in range(3):\n cuboid(ax, (2.1 * i, 0.4, z), (1.6, 1.2, 0.45), c, alpha=0.45)\n for i in range(3):\n x = 2.1 * i + 1.25\n ax.plot([x, x], [1.0, 1.0], [3.2, 2.12], color=\'0.25\', lw=1.1, zorder=8)\n ax.plot([x], [1.0], [2.12], marker=\'v\', color=\'0.25\', ms=5, zorder=8)\n for i in range(3):\n for z, c, s in ((0.0, GREEN, \'P\'), (1.6, BLUE, \'I\'), (3.2, RED, \'O\')):\n ax.text(2.1 * i + 0.55, 1.0, z + 0.68, \'%s%d\' % (s, i + 1), ha=\'center\', fontsize=9.5,\n color=c, weight=\'bold\', zorder=10)\n ax.set_xlim(-0.3, 6.3); ax.set_ylim(-0.3, 2.3); ax.set_zlim(0, 4.2)\n ax.view_init(elev=14, azim=-72)\n lines = [\n (RED, \'open inputs\'),\n (RED, \'O1 (D) or local BP along the tuning\'),\n (RED, \'O2 slice ratio in four dimensions\'),\n (RED, \'O3 tree bounds (T1)-(T3)\'),\n (BLUE, \'proved implications\'),\n (BLUE, \'I1 (D) or local BP: gap for every limit\'),\n (BLUE, \'I2 ratio iff nontrivial flowed limit\'),\n (BLUE, \'I3 tree bounds give the ratio\'),\n (GREEN, \'proved at fixed spacing\'),\n (GREEN, \'P1 gap for every simple group\'),\n (GREEN, \'P2 SU(2), SU(3) with blocks\'),\n (GREEN, \'P3 (D) and BP at strong coupling\'),\n (\'0.25\', \'arrows: an open input and the\'),\n (\'0.25\', \'implication that consumes it\'),\n ]\n y = 0.93\n for k, (c, s) in enumerate(lines):\n bold = k % 4 == 0 and k < 12\n fig.text(0.6, y, s, color=c, fontsize=9.5 if bold else 9, weight=\'bold\' if bold else \'normal\')\n y -= 0.058 if not (k % 4 == 3 and k < 12) else 0.1\n save(fig, \'fig_logic.png\')\n\n\ndef fig_packet():\n """The packet f_0, its reflection and its translate in a three-dimensional slice of spacetime."""\n fig = plt.figure(figsize=(7.0, 4.4))\n ax = fig.add_axes([0.0, 0.08, 1.0, 0.92], projection=\'3d\'); ax.set_axis_off()\n ax.set_box_aspect((1, 1, 1.3), zoom=1.2)\n ax.computed_zorder = False\n L = 2.2\n P = [[(-L, -L, 0), (L, -L, 0), (L, L, 0), (-L, L, 0)]]\n ax.add_collection3d(Poly3DCollection(P, facecolors=\'0.7\', alpha=0.25, edgecolors=\'0.4\', linewidths=0.6))\n u, v = np.meshgrid(np.linspace(0, 2 * np.pi, 40), np.linspace(0, np.pi, 20))\n def blob(tc, color, alpha):\n x = 0.9 * np.cos(u) * np.sin(v); y = 0.9 * np.sin(u) * np.sin(v); t = tc + 0.35 * np.cos(v)\n ax.plot_surface(x, y, t, color=color, alpha=alpha, linewidth=0, shade=True)\n blob(1.05, BLUE, 0.55)\n blob(-1.05, GREY, 0.45)\n blob(2.55, GREEN, 0.5)\n ax.plot([1.6, 1.6], [1.6, 1.6], [-0.7, 1.4], color=\'0.3\', lw=0.8, ls=\':\')\n for t, lab in ((0.7, r\'$t_0$\'), (1.4, r\'$t_1$\')):\n ax.plot([1.45, 1.75], [1.6, 1.6], [t, t], color=\'0.3\', lw=0.9)\n ax.text(1.85, 1.6, t, lab, fontsize=10, va=\'center\')\n ax.plot([-1.3, -1.3], [-1.3, -1.3], [1.05, 2.55], color=\'k\', lw=1.0)\n ax.text(-1.55, -1.3, 1.8, r\'$\\sigma$\', fontsize=11, ha=\'right\')\n for y, lab, c in ((0.817, r\'$\\tau_\\sigma f_0$\', GREEN), (0.582, r\'$f_0$\', BLUE),\n (0.26, r\'$\\vartheta f_0$\', \'0.25\')):\n fig.text(0.6, y, lab, color=c, fontsize=11, va=\'center\')\n fig.text(0.215, 0.425, r\'$t=0$\', fontsize=10, color=\'0.25\')\n ax.set_xlim(-L, L); ax.set_ylim(-L, L); ax.set_zlim(-1.6, 3.3)\n ax.view_init(elev=12, azim=-55)\n fig.text(0.02, 0.04, r\'$C_k(\\sigma)=\\langle\\Psi_{A_k},\\mathbb{T}_k^{\\sigma/a_k}\\Psi_{A_k}\\rangle$:\'\n r\' the reflected packet $\\vartheta f_0$ paired with the packet translated by $\\sigma$\',\n fontsize=9.5)\n save(fig, \'fig_packet.png\')\n\n\ndef su2_energy(a, j, g2=1.0, ell=1.0):\n beta = 4.0 / (g2 * a * a)\n return -(ell / a ** 2) * math.log(ive(int(2 * j + 1), beta) / ive(1, beta))\n\n\ndef fig_twod():\n """Two-dimensional SU(N): the cylinder lattice and the convergence of the energies."""\n fig = plt.figure(figsize=(7.4, 3.5))\n ax = fig.add_axes([0.0, 0.02, 0.47, 0.96], projection=\'3d\'); clean(ax, (1, 1, 1.5))\n ax.computed_zorder = False\n L, T = 12, 6\n th = 2 * np.pi * np.arange(L) / L\n segs = []\n for t in range(T):\n for i in range(L):\n p = (math.cos(th[i]), math.sin(th[i]), t); q = (math.cos(th[(i + 1) % L]), math.sin(th[(i + 1) % L]), t)\n segs.append([p, q])\n if t + 1 < T:\n segs.append([p, (p[0], p[1], t + 1)])\n ax.add_collection3d(Line3DCollection(segs, colors=\'0.72\', linewidths=0.7))\n t = 2\n ring = [(math.cos(s), math.sin(s), t) for s in np.linspace(0, 2 * np.pi, 120)]\n ax.plot(*zip(*ring), color=BLUE, lw=2.4)\n ring = [(math.cos(s), math.sin(s), t + 1) for s in np.linspace(0, 2 * np.pi, 120)]\n ax.plot(*zip(*ring), color=GREEN, lw=2.4)\n for i in (1, 2, 3):\n a0, a1 = th[i], th[i + 1]\n quad = [[(math.cos(a0), math.sin(a0), t), (math.cos(a1), math.sin(a1), t),\n (math.cos(a1), math.sin(a1), t + 1), (math.cos(a0), math.sin(a0), t + 1)]]\n ax.add_collection3d(Poly3DCollection(quad, facecolors=RED, alpha=0.45, edgecolors=RED))\n ax.text2D(0.02, 0.62, r\'$V^{\\prime}=QV$\', color=GREEN, fontsize=11, transform=ax.transAxes)\n ax.text2D(0.12, 0.40, r\'$V$\', color=BLUE, fontsize=11, transform=ax.transAxes)\n ax.text2D(0.78, 0.56, r\'$W_x$\', color=RED, fontsize=11, transform=ax.transAxes)\n ax.set_xlim(-1.2, 1.2); ax.set_ylim(-1.2, 1.2); ax.set_zlim(0, T - 1)\n ax.view_init(elev=18, azim=-60)\n ax.text2D(0.0, 0.95, \'(a) holonomy on the circle\', transform=ax.transAxes)\n bx = fig.add_axes([0.57, 0.17, 0.4, 0.7])\n a = np.geomspace(0.002, 0.25, 60)\n for j, c in ((0.5, BLUE), (1.0, GREEN), (1.5, RED)):\n E = [su2_energy(x, j) for x in a]\n bx.plot(a, E, color=c, lw=1.6, label=r\'$j=%s$\' % (\'1/2\' if j == 0.5 else (\'1\' if j == 1 else \'3/2\')))\n bx.axhline(j * (j + 1) / 2, color=c, lw=0.6, ls=\'--\')\n bx.set_xscale(\'log\'); bx.set_xlabel(r\'lattice spacing $a$\'); bx.set_ylabel(r\'$E_{j,k}$\')\n bx.set_title(r\'(b) $\\mathrm{SU}(2)$, $g^2=\\ell=1$; limits $j(j+1)/2$\', fontsize=9.5, loc=\'left\')\n bx.legend(frameon=False, fontsize=9, loc=\'upper left\')\n bx.set_ylim(0, 2.3)\n save(fig, \'fig_twod.png\')\n\n\ndef fig_slice():\n """D_k(r)/D_k(r_0) over (r, a): two-dimensional SU(2) against a field whose mass is fixed in lattice units."""\n fig = plt.figure(figsize=(7.4, 3.6))\n r = np.linspace(0.5, 2.0, 30); la = np.linspace(1, 8, 30)\n R, LA = np.meshgrid(r, la); A = 2.0 ** (-LA)\n E2 = np.vectorize(lambda x: su2_energy(x, 0.5))(A)\n Z1 = np.exp(-(R - 0.5) * E2)\n mk = np.arccosh(1 + 0.5 ** 2 / 2) / A\n Z2 = np.exp(-(R - 0.5) * mk)\n for k, (Z, title, c) in enumerate(((Z1, r\'(a) $\\mathrm{SU}(2)$ in two dimensions\', BLUE),\n (Z2, r\'(b) mass $1/2$ in lattice units\', RED))):\n ax = fig.add_subplot(1, 2, k + 1, projection=\'3d\')\n ax.plot_surface(R, LA, Z, color=c, alpha=0.75, linewidth=0.2, edgecolor=\'w\', shade=True)\n ax.set_xlabel(r\'$r$\', labelpad=-6); ax.set_ylabel(r\'$\\log_2(1/a)$\', labelpad=-4)\n ax.tick_params(labelsize=7, pad=-2)\n ax.set_zlim(0, 1.05)\n ax.view_init(elev=24, azim=-128)\n ax.text2D(0.0, 0.97, title, transform=ax.transAxes, fontsize=9.5)\n fig.text(0.5, 0.02, r\'height: $D_k(r)/D_k(1/2)$ for $g^2=\\ell=1$\', ha=\'center\', fontsize=9.5)\n fig.subplots_adjust(left=0.0, right=0.97, wspace=0.05, top=0.97, bottom=0.08)\n save(fig, \'fig_slice.png\')\n\n\ndef fig_blocking():\n """Block averages between the reflection plane and the packet, at three block sizes."""\n fig = plt.figure(figsize=(7.4, 3.4))\n D = 4.0\n for k, (n, lab, c) in enumerate(((4, r\'$b=d/4$\', GREEN), (2, r\'$b=d/2$\', BLUE), (1, r\'$b=d$\', RED))):\n ax = fig.add_axes([k / 3, 0.1, 1 / 3, 0.88], projection=\'3d\'); clean(ax, (1, 1, 1.25))\n ax.computed_zorder = False\n P = [[(0, 0, 0), (D, 0, 0), (D, D, 0), (0, D, 0)]]\n ax.add_collection3d(Poly3DCollection(P, facecolors=\'0.7\', alpha=0.3, edgecolors=\'0.4\', linewidths=0.6))\n s_ = D / n\n for i, j, l in itertools.product(range(n), range(n), range(n)):\n if i == n - 1 or j == 0 or l == n - 1:\n cuboid(ax, (i * s_, j * s_, l * s_), (s_, s_, s_ * 0.98), c, alpha=0.07, lw=0.5, edge=c)\n u, v = np.meshgrid(np.linspace(0, 2 * np.pi, 40), np.linspace(0, np.pi, 20))\n ax.plot_surface(D / 2 + 1.1 * np.cos(u) * np.sin(v), D / 2 + 1.1 * np.sin(u) * np.sin(v),\n D + 0.75 + 0.35 * np.cos(v), color=\'#8e44ad\', alpha=0.6, linewidth=0)\n ax.plot([D, D], [D, D], [0, D + 0.75], color=\'k\', lw=1.0)\n ax.set_xlim(0, D); ax.set_ylim(0, D); ax.set_zlim(0, D + 1.2)\n ax.view_init(elev=14, azim=-58)\n ax.text2D(0.42, 0.02, lab, color=c, fontsize=11, transform=ax.transAxes)\n if k == 0:\n ax.text2D(0.72, 0.76, r\'$F$\', color=\'#8e44ad\', fontsize=11, transform=ax.transAxes)\n ax.text2D(0.91, 0.5, r\'$d$\', fontsize=11, transform=ax.transAxes)\n ax.text2D(0.02, 0.2, r\'$t=0$\', fontsize=10, color=\'0.25\', transform=ax.transAxes)\n fig.text(0.5, 0.02, r\'block averages of side $b$ between the plane $t=0$ and the packet $F$ at height $d$\',\n ha=\'center\', fontsize=9.5)\n save(fig, \'fig_blocking.png\')\n\n\nif __name__ == \'__main__\':\n fig_logic(); fig_packet(); fig_twod(); fig_slice(); fig_blocking()\n', 'make_split.py': '"""Figures for the split inequality at strong coupling and for the\ncoarsest-scale condition.\n\nfig_bpsplitstrong: (a) the exterior information of one fine cube. Changing a\ncoarse link e moves the fibre law through the marked link l(e) inside the\ncube, by at most q per partner sum, and the cube, resampled given its\nexterior, feels the change through its boundary links, again by at most q;\ntwo cubes at distance s see each other through fibre correlations that\ndecay like xi^(s-n\'-1)/(1-xi) (Theorems thm:bpexterior, thm:bpsplitstrong).\n(b) the constants C_A and C_B (bn/n\')^4 of Theorem thm:bpsplitstrong for\nSU(2) against |beta_W|, at n\' = 8 and in the limit n\' -> infinity, with the\nrefinement value 1 (Corollary cor:bpsplitranges).\n\nfig_bphidden: (a) the law of Proposition prop:bphidden(ii): one sign S,\ndrawn once for the torus, chooses between two product tilts of the selected\nplaquettes. (b) the law of the spatial average F under that measure, drawn\nwith normal approximations of its two components (an illustration only),\nfor L = 8, 16, 32, epsilon = 1/2, SU(2): the two modes at +-epsilon/4 do\nnot merge as L grows, while resampling one cube moves F by at most\n2 r_x / M.\n\nRun from this directory: python3 make_split.py."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom matplotlib.patches import Rectangle, FancyArrowPatch, Polygon\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY, GOLD = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\', \'#d4a017\'\n\n\ndef constants(beta, n):\n xi = 4.5 * beta\n c = beta / 4\n q = xi / (1 - xi)\n if n is None:\n alpha, rn = 0.0, 16.0\n else:\n alpha = c * (18 * n - 3) / ((1 - 18 * c) * n * n)\n rn = ((2 * n + 3) ** 4 + 10 * (n + 2) ** 3 * xi * (8 - 5 * xi + 4 * xi ** 2 - xi ** 3) / (1 - xi) ** 5) / n ** 4\n eta = q * np.sqrt(rn / (1 - alpha))\n return 1 / ((1 - eta) * (1 - alpha)), 1 / (1 - q * q - eta)\n\n\ndef fig_bpsplitstrong():\n fig = plt.figure(figsize=(9.6, 4.1))\n ax = fig.add_axes([0.0, 0.02, 0.56, 0.93])\n ax.set_xlim(-0.6, 26.6); ax.set_ylim(-1.6, 13.2); ax.set_aspect(\'equal\'); ax.axis(\'off\')\n W, H, b = 26, 12, 4\n for x in range(W + 1):\n ax.plot([x, x], [0, H], color=GREY, lw=0.3, alpha=0.6)\n for y in range(H + 1):\n ax.plot([0, W], [y, y], color=GREY, lw=0.3, alpha=0.6)\n for x in range(0, W + 1, b):\n ax.plot([x, x], [0, H], color=INK, lw=1.1, alpha=0.55)\n for y in range(0, H + 1, b):\n ax.plot([0, W], [y, y], color=INK, lw=1.1, alpha=0.55)\n cubes = [(2, 3, 6), (17, 3, 6)]\n for (x0, y0, s) in cubes:\n ax.add_patch(Rectangle((x0, y0), s, s, fc=RED, ec=RED, alpha=0.10, lw=0))\n ax.add_patch(Rectangle((x0, y0), s, s, fc=\'none\', ec=RED, lw=1.6))\n ax.add_patch(Rectangle((x0 - 1, y0 - 1), s + 2, s + 2, fc=\'none\', ec=RED, lw=0.9, ls=(0, (3, 2))))\n # coarse link e: path along y = 4 from x = 4 to 8, marked link inside the cube\n ax.plot([4, 8], [4, 4], color=BLUE, lw=3.2, solid_capstyle=\'butt\')\n ax.plot([6, 7], [4, 4], color=GOLD, lw=4.2, solid_capstyle=\'butt\')\n ax.text(4.2, 3.25, r\'$\\pi(e)$\', color=BLUE, fontsize=9)\n ax.text(6.0, 4.35, r\'$l(e)$\', color=\'#9a7400\', fontsize=9)\n ax.text(2.1, 9.35, r"$V\'_{x\'}$", color=RED, fontsize=10)\n ax.text(17.1, 9.35, r"$V\'_{x\'\'}$", color=RED, fontsize=10)\n ax.text(0.9, 1.1, r"$\\partial V\'_{x\'}$", color=RED, fontsize=8.5)\n a1 = FancyArrowPatch((6.5, 4.2), (8.6, 7.6), arrowstyle=\'-|>\', mutation_scale=10, color=GREEN, lw=1.2,\n connectionstyle=\'arc3,rad=-0.3\')\n ax.add_patch(a1)\n ax.text(8.9, 7.7, r\'fibre: $q$\', color=GREEN, fontsize=9)\n a2 = FancyArrowPatch((8.6, 7.1), (5.2, 6.4), arrowstyle=\'-|>\', mutation_scale=10, color=GREEN, lw=1.2,\n connectionstyle=\'arc3,rad=-0.3\')\n ax.add_patch(a2)\n ax.text(3.6, 10.6, r\'exterior information $\\leq q^2$\', color=GREEN, fontsize=9)\n ax.annotate(\'\', xy=(16.0, 6.0), xytext=(9.0, 6.0),\n arrowprops=dict(arrowstyle=\'<|-|>\', color=INK, lw=1.0, ls=(0, (4, 2))))\n ax.text(12.5, 6.35, r"$\\xi^{s-n\'-1}/(1-\\xi)$", ha=\'center\', fontsize=9, color=INK)\n ax.text(12.5, 5.2, \'fibre decay\', ha=\'center\', fontsize=8.5, color=\'#555555\')\n ax.text(0.0, -1.2, r\'thin: fine links; thick: paths of the coarse links ($b=4$)\', fontsize=8.5, color=\'#444444\')\n ax.text(-0.5, 12.6, \'(a)\', fontsize=11)\n\n bx = fig.add_axes([0.64, 0.15, 0.34, 0.75])\n beta = np.linspace(0, 0.012, 200)\n for n, ls, lab in ((8, \'-\', r"$n\'=8$"), (None, \'--\', r"$n\'\\to\\infty$")):\n ca, cb = np.array([constants(t, n) for t in beta]).T\n bx.plot(beta, ca, ls, color=RED, lw=1.5, label=r\'$C_A$, \' + lab)\n bx.plot(beta, cb, ls, color=BLUE, lw=1.5, label=r"$C_B(bn/n\')^4$, " + lab)\n bx.axhline(1, color=GREEN, lw=1.0)\n bx.text(0.0062, 1.015, \'Haar refinements\', color=GREEN, fontsize=8.5)\n bx.axvline(0.01, color=GREY, lw=0.8, ls=\':\')\n bx.set_xlabel(r\'$|\\beta_W|$\'); bx.set_xlim(0, 0.012); bx.set_ylim(0.95, 1.75)\n bx.legend(fontsize=7.6, frameon=False, loc=\'upper left\')\n bx.set_title(\'(b) SU(2)\', fontsize=10, loc=\'left\')\n save(fig, \'fig_bpsplitstrong.png\')\n\n\ndef fig_bphidden():\n fig = plt.figure(figsize=(9.6, 4.2))\n ax = fig.add_axes([0.0, 0.0, 0.52, 1.0], projection=\'3d\')\n clean3d(ax)\n ax.set_box_aspect((1, 1, 0.8))\n L = 8\n rng = np.random.default_rng(3)\n for z, col, lab in ((2.6, RED, r\'$S=+1$: $\\prod_i(1+\\epsilon X_i)$\'), (0.0, BLUE, r\'$S=-1$: $\\prod_i(1-\\epsilon X_i)$\')):\n for x in range(L + 1):\n ax.plot([x, x], [0, L], [z, z], color=GREY, lw=0.35)\n ax.plot([0, L], [x, x], [z, z], color=GREY, lw=0.35)\n X, Y = np.meshgrid([0, L], [0, L])\n ax.plot_surface(X, Y, np.full_like(X, z, dtype=float), color=col, alpha=0.05, linewidth=0, shade=False)\n for i in range(0, L, 2):\n for j in range(0, L, 2):\n a = 0.25 + 0.55 * rng.random()\n ax.add_collection3d(matplotlib.collections.PolyCollection(\n [[(i, j), (i + 1, j), (i + 1, j + 1), (i, j + 1)]], facecolors=col, alpha=a, edgecolors=col),\n zs=z, zdir=\'z\')\n ax.text(L + 0.4, 0, z + 0.15, lab, fontsize=9, color=col)\n ax.text(-1.4, -1.0, 1.25, r\'one sign $S$\', fontsize=9.5, color=INK)\n ax.quiver(-0.5, -0.5, 1.5, 0, 0, 0.9, color=INK, lw=1.2, arrow_length_ratio=0.25)\n ax.quiver(-0.5, -0.5, 1.1, 0, 0, -0.9, color=INK, lw=1.2, arrow_length_ratio=0.25)\n ax.view_init(elev=22, azim=-62)\n ax.set_xlim(0, L); ax.set_ylim(0, L); ax.set_zlim(0, 3.0)\n ax.text2D(0.02, 0.93, \'(a)\', transform=ax.transAxes, fontsize=11)\n\n bx = fig.add_axes([0.60, 0.20, 0.37, 0.68])\n eps, s2 = 0.5, 0.25\n m, v = eps * s2, s2 - (eps * s2) ** 2\n x = np.linspace(-0.3, 0.3, 800)\n for Lt, col in ((8, GREY), (16, BLUE), (32, INK)):\n M = (Lt / 2) ** 4\n sd = np.sqrt(v / M)\n dens = 0.5 * (np.exp(-(x - m) ** 2 / (2 * sd * sd)) + np.exp(-(x + m) ** 2 / (2 * sd * sd)))\n bx.plot(x, dens / dens.max(), color=col, lw=1.3, label=r\'$L=%d$\' % Lt)\n bx.axvline(m, color=RED, lw=0.8, ls=\':\'); bx.axvline(-m, color=BLUE, lw=0.8, ls=\':\')\n bx.set_xlabel(r\'$F=M^{-1}\\sum_i X_i$\'); bx.set_yticks([]); bx.set_ylabel(\'density, unit peak\', fontsize=9); bx.set_ylim(0, 1.35)\n bx.legend(fontsize=8.5, frameon=False, loc=\'upper center\')\n bx.set_title(r\'(b) law of $F$, $\\mathrm{SU}(2)$, $\\epsilon=1/2$\', fontsize=10, loc=\'left\')\n fig.text(0.60, 0.015, r\'two modes at $\\pm\\epsilon s_2^2$; one cube moves $F$ by at most $2r_x/M$\',\n fontsize=8.3, color=\'#444444\')\n save(fig, \'fig_bphidden.png\')\n\n\nif __name__ == \'__main__\':\n fig_bpsplitstrong()\n fig_bphidden()\n', 'make_thickties.py': '"""Figure for Proposition prop:thickties and Lemma lem:ties:\n(a) two branch values f_{x_a}, f_{x\'_a} over two coordinates of xi when\nu_a = w_a = u with d(u, I) = s: over the open set U_0 they differ by at most\n2s, so the near-ties form a set of positive measure, not a thin band;\n(b) the set U_0 in the coordinates delta(xi_a, I) and max_{b != a}\ndelta(xi_b, I), and, for comparison, a thin band of width t around a tie\nhypersurface, the shape that a bound Haar(T(t)) <= M t would need.\nSchematic, not to scale.\nRun from this directory: python3 make_thickties.py. Writes fig_thickties.png."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom matplotlib.patches import Rectangle\nfrom make_figures import save, clean3d\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nBLUE, RED, GREEN, INK, GREY = \'#3b6fb6\', \'#c0392b\', \'#2e8b57\', \'#222222\', \'#9aa5b1\'\n\nfig = plt.figure(figsize=(9.0, 3.9))\nax = fig.add_axes([-0.02, 0.02, 0.55, 0.96], projection=\'3d\')\nclean3d(ax)\nx, y = np.meshgrid(np.linspace(0, 1, 70), np.linspace(0, 0.8, 60))\ndx = np.maximum(np.maximum(17 / 32 - x, x - 31 / 32), 0)\ndy = np.maximum(y - 15 / 32, 0)\ndist = np.hypot(dx, dy)\nw = 1 - np.exp(-(dist / 0.12) ** 2)\nf1 = 0.55 + 0.45 * x - 0.25 * y ** 2\ns = 0.02\nf2 = f1 + s * np.sin(9 * x) * np.cos(7 * y) + w * 0.28\nax.plot_surface(x, y, f1, color=BLUE, alpha=0.55, lw=0, rstride=2, cstride=2)\nax.plot_surface(x, y, f2, color=GREEN, alpha=0.45, lw=0, rstride=2, cstride=2)\nxs = np.array([17 / 32, 31 / 32, 31 / 32, 17 / 32, 17 / 32])\nys = np.array([0, 0, 15 / 32, 15 / 32, 0])\nax.plot(xs, ys, np.full(5, 0.35), color=RED, lw=1.4)\nfor xx, yy in zip(xs[:4], ys[:4]):\n ax.plot([xx, xx], [yy, yy], [0.35, 0.55 + 0.45 * xx - 0.25 * yy ** 2], color=RED, lw=0.6, ls=\':\')\nax.text(0.62, 0.05, 0.25, r\'$U_0$\', color=RED, fontsize=11)\nax.text(0.0, -0.05, 0.42, r\'$f_{x_a}$\', color=BLUE, fontsize=11)\nax.text(0.0, 0.8, 1.0, r\'$f_{x^\\prime_a}$\', color=GREEN, fontsize=11)\nfig.text(0.36, 0.33, r\'$|f_{x_a}-f_{x^\\prime_a}|\\leq 2s$ over $U_0$\', color=INK, fontsize=9)\nax.set_zlim(0.35, 1.2)\nax.view_init(elev=16, azim=-70)\nfig.text(0.02, 0.93, \'(a)\', fontsize=11)\n\nbx = fig.add_axes([0.6, 0.15, 0.37, 0.75])\nbx.add_patch(Rectangle((17 / 32, 0), 14 / 32, 15 / 32, facecolor=RED, alpha=0.25, edgecolor=RED))\nbx.text(0.66, 0.2, r\'$U_0\\subset T(t)$\', color=RED)\ntt = np.linspace(0, 1, 100)\ncurve = 0.75 - 0.35 * (tt - 0.1) ** 2\nbx.fill_between(tt[:40], curve[:40] - 0.025, curve[:40] + 0.025, color=BLUE, alpha=0.35)\nbx.plot(tt[:40], curve[:40], color=BLUE, lw=1)\nbx.text(0.02, 0.83, r\'band of width $t$\', color=BLUE, fontsize=9)\nbx.set_xlim(0, 1); bx.set_ylim(0, 1)\nbx.set_xlabel(r\'$\\delta(\\xi_a,I)$\'); bx.set_ylabel(r\'$\\max_{b\\neq a}\\delta(\\xi_b,I)$\')\nbx.set_xticks([0, 17 / 32, 31 / 32]); bx.set_xticklabels([\'0\', r\'$\\frac{17}{32}$\', r\'$\\frac{31}{32}$\'])\nbx.set_yticks([0, 15 / 32]); bx.set_yticklabels([\'0\', r\'$\\frac{15}{32}$\'])\nfor sp in (\'top\', \'right\'):\n bx.spines[sp].set_visible(False)\nfig.text(0.56, 0.93, \'(b)\', fontsize=11)\nsave(fig, \'fig_thickties.png\')\n', 'make_whitney.py': '"""Figure of the extension of Theorem "effectiveupper": (a) one direction of a\nblock of side L = 4, the block centres c_z as nodes, the hat functions and\nthe straight path of length L from a site, which meets three segments\nbetween centres; the averages over the block are the weights 1/8, 3/4, 1/8;\n(b) the symbol 3/4 + cos(theta)/4 of this filter, the same at every scale,\nagainst the modulus of the filter obtained with the coarse sites as nodes,\nwhich tends to zero at theta = pi. Run from this directory:\npython3 make_whitney.py. Writes fig_whitney.png."""\nimport numpy as np\nimport matplotlib\nmatplotlib.use(\'Agg\')\nimport matplotlib.pyplot as plt\nfrom make_figures import save\n\nplt.rcParams.update({\'font.family\': \'serif\', \'font.size\': 10, \'mathtext.fontset\': \'cm\'})\nGREY, BLUE, RED, ORANGE, GREEN, INK = \'#c9c9c9\', \'#3b6fb6\', \'#c0392b\', \'#e67e22\', \'#2e8b57\', \'#222222\'\n\n\ndef blocks(ax):\n L = 4\n xs = np.arange(-6, 10)\n for b in range(-2, 3):\n ax.axvspan(L * b - 0.5, L * b + L - 0.5, color=GREY if b % 2 else \'#ececec\', alpha=0.6, lw=0)\n ax.plot(xs, np.zeros_like(xs), \'o\', color=INK, ms=3)\n t = np.linspace(-8, 12, 801)\n cols = {-1: GREEN, 0: BLUE, 1: ORANGE}\n for z in (-1, 0, 1):\n c = L * z + (L - 1) / 2\n ax.plot(t, 1.1 * np.maximum(0, 1 - np.abs(t - c) / L), color=cols[z], lw=1.6)\n ax.plot([c], [0], marker=\'D\', color=cols[z], ms=6)\n ax.text(c, -0.2, r\'$c_{%d}$\' % z if z >= 0 else r\'$c_{-1}$\', ha=\'center\', va=\'top\', fontsize=10, color=cols[z])\n s = 2\n ax.annotate(\'\', xy=(s + L, 1.35), xytext=(s, 1.35),\n arrowprops=dict(arrowstyle=\'->\', color=RED, lw=1.6))\n ax.text(s + L / 2, 1.42, r\'path of length $L$ from $x$\', ha=\'center\', va=\'bottom\', color=RED, fontsize=9.5)\n ax.plot([s, s], [0, 1.35], ls=\':\', color=RED, lw=1)\n for z, wgt in zip((-1, 0, 1), (r\'$\\frac{1}{8}$\', r\'$\\frac{3}{4}$\', r\'$\\frac{1}{8}$\')):\n ax.text(L * z + (L - 1) / 2, 0.55 if z == 0 else 0.35, wgt, ha=\'center\', fontsize=12, color=cols[z],\n bbox=dict(fc=\'white\', ec=\'none\', alpha=0.8, pad=1))\n ax.text(1.5, -0.55, r\'block $B_k(0)$, $L=4$\', ha=\'center\', fontsize=9.5)\n ax.set_xlim(-6.5, 9.5)\n ax.set_ylim(-0.75, 1.75)\n ax.axis(\'off\')\n ax.set_title(\'(a) nodes at the block centres\', fontsize=10.5)\n\n\ndef symbol(ax):\n th = np.linspace(0, np.pi, 400)\n ax.plot(th, 0.75 + 0.25 * np.cos(th), color=BLUE, lw=2, label=r\'centres: $\\frac{3}{4}+\\frac{1}{4}\\cos\\theta$, every $L$\')\n for L, ls in ((4, \'--\'), (16, \':\')):\n a = (L + 1) / (2 * L)\n ax.plot(th, np.abs(a + (1 - a) * np.exp(1j * th)), color=RED, ls=ls, lw=1.6,\n label=r\'coarse sites, $L=%d$\' % L)\n ax.axhline(0.5, color=GREY, lw=0.8)\n ax.set_xlim(0, np.pi)\n ax.set_ylim(0, 1.05)\n ax.set_xticks([0, np.pi / 2, np.pi])\n ax.set_xticklabels([\'0\', r\'$\\pi/2$\', r\'$\\pi$\'])\n ax.set_xlabel(r\'$\\theta$\')\n ax.set_ylabel(\'modulus of the filter symbol\')\n ax.legend(loc=\'lower left\', fontsize=8.5, frameon=False)\n ax.set_title(\'(b) the filter in one direction\', fontsize=10.5)\n\n\nfig, axs = plt.subplots(1, 2, figsize=(7.6, 2.9), gridspec_kw={\'width_ratios\': [1.45, 1]})\nblocks(axs[0])\nsymbol(axs[1])\nfig.tight_layout()\nsave(fig, \'fig_whitney.png\')\n', 'nonabelian_filling.py': '"""Checks of the nonabelian filling lemma (Lemma lem:nonabelianfilling of\nthe forest paper, Sec. ssec:largefields).\n\nFor boxes [0,l]^4 and SU(2) boundary fields that are gauge transforms, by\narbitrary (large) vertex gauges, of fields with small plaquettes, this\nprogram\n\n (a) builds the coordinate-path gauge of each facet and checks that its\n links have angle at most 2 l rho_s (l = 2, 3, 4);\n (b) glues the facet gauges in the order f1+, f2+, f2-, f3+, f3-, f4+,\n f4-, f1- through principal logarithms and McShane extensions, and\n checks the agreement on the earlier facets and the bounds\n M_k <= C_k l rho_s (l = 2, 3, 4);\n (c) checks the curl bound |(dA)_p| <= rho_s + 8 M^2 for the logarithms\n of the gauged boundary links;\n (d) for l = 2, 3 evaluates the radial cubical extension B, integrates its\n transports along every link of the box piece by piece between the\n cone interfaces, undoes the gauge, and checks that the boundary\n links are reproduced and that every plaquette of the box has angle\n at most K rho_s, K = 42 C_8 + 20;\n (e) checks the constants C_k, K, eps_0 and the numerical inequalities of\n the proof in exact rational arithmetic.\n\nThe boundary fields satisfy l^2 rho_s <= eps_0, so rho_s is of order\n1e-21; the computation uses mpmath with 60 digits. These are numerical\nchecks of the construction, not interval certificates; the proof in the\npaper covers every l >= 2.\n\nUsage: python3 nonabelian_filling.py\n"""\n\nimport itertools\nimport random\nfrom fractions import Fraction as Fr\n\nimport mpmath as mp\n\nmp.mp.dps = 60\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append((name, bool(ok)))\n print(("ok " if ok else "FAIL ") + name)\n\n\n# ---------------------------------------------------------------- quaternions\n\ndef qmul(a, b):\n a0, a1, a2, a3 = a\n b0, b1, b2, b3 = b\n return (a0 * b0 - a1 * b1 - a2 * b2 - a3 * b3,\n a0 * b1 + a1 * b0 + a2 * b3 - a3 * b2,\n a0 * b2 - a1 * b3 + a2 * b0 + a3 * b1,\n a0 * b3 + a1 * b2 - a2 * b1 + a3 * b0)\n\n\ndef qinv(a):\n return (a[0], -a[1], -a[2], -a[3])\n\n\nONE = (mp.mpf(1), mp.mpf(0), mp.mpf(0), mp.mpf(0))\n\n\ndef vnorm(v):\n return mp.sqrt(v[0] ** 2 + v[1] ** 2 + v[2] ** 2)\n\n\ndef angle(q):\n return mp.atan2(vnorm(q[1:]), q[0])\n\n\ndef qexp(v):\n t = vnorm(v)\n if t == 0:\n return ONE\n s = mp.sin(t) / t\n return (mp.cos(t), v[0] * s, v[1] * s, v[2] * s)\n\n\ndef qlog(q):\n t = angle(q)\n n = vnorm(q[1:])\n if n == 0:\n return (mp.mpf(0),) * 3\n return tuple(c * t / n for c in q[1:])\n\n\ndef vadd(u, w):\n return tuple(a + b for a, b in zip(u, w))\n\n\ndef vscale(c, u):\n return tuple(c * a for a in u)\n\n\ndef haar(rng):\n v = [mp.mpf(rng.gauss(0, 1)) for _ in range(4)]\n n = mp.sqrt(sum(x * x for x in v))\n return tuple(x / n for x in v)\n\n\ndef small(rng, amp):\n return tuple(mp.mpf(rng.uniform(-1, 1)) * amp for _ in range(3))\n\n\n# ----------------------------------------------------------------- constants\n\ndef constants():\n C = [None, 2]\n for _ in range(2, 9):\n C.append(11 * C[-1] + 24)\n return C\n\n\nC = constants()\nC8 = C[8]\nK = 42 * C8 + 20\nEPS0 = Fr(1, 100 * C8 * C8)\nSQRT3_UP = Fr(17320509, 10 ** 7) # > sqrt(3)\n\n\ndef exact_checks():\n check("C_8 = 85743550", C8 == 85743550)\n check("K = 42 C_8 + 20 = 3601229120", K == 3601229120)\n check("eps_0 = 1/735195636660250000",\n EPS0 == Fr(1, 735195636660250000))\n check("sqrt(3) < 1.7320509", SQRT3_UP ** 2 > 3)\n check("6 sqrt(3) <= 11", 6 * SQRT3_UP <= 11)\n check("12 sqrt(3) + 2 <= 24", 12 * SQRT3_UP + 2 <= 24)\n check("9 (C_8 + 2) eps_0 < 1/2", 9 * (C8 + 2) * EPS0 < Fr(1, 2))\n check("C_8 eps_0 / 2 < 1/2 (M < 1/2 for l >= 2)",\n C8 * EPS0 / 2 < Fr(1, 2))\n check("C_8^2 eps_0 = 1/100 (M^2 <= rho_s/100)",\n C8 * C8 * EPS0 == Fr(1, 100))\n lhs = 24 * SQRT3_UP * C8 + 9 * SQRT3_UP + (72 * SQRT3_UP + 216) / 100\n check("24 sqrt3 C_8 + 9 sqrt3 + (72 sqrt3 + 216)/100 < 42 C_8 + 20",\n lhs < K)\n check("(1/2)/sin(1/2) < 2", mp.mpf("0.5") / mp.sin(mp.mpf("0.5")) < 2)\n ok = all(2 * mp.asin(x / 2) <= x * (1 + x * x)\n for x in [mp.mpf(k) / 1000 for k in range(1, 1001)])\n check("2 arcsin(x/2) <= x (1 + x^2) on (0,1]", ok)\n check("(4 h 3 sqrt3 M)^2 / 2 = 216 M^2 h^2", Fr(1, 2) * 16 * 9 * 3 == 216)\n\n\n# ----------------------------------------------------------------- lattice\n\ndef unit(m):\n v = [0, 0, 0, 0]\n v[m] = 1\n return tuple(v)\n\n\ndef add(x, y):\n return tuple(a + b for a, b in zip(x, y))\n\n\ndef box(l):\n verts = list(itertools.product(range(l + 1), repeat=4))\n links = [(x, m) for x in verts for m in range(4) if x[m] < l]\n plaqs = [(x, m, n) for x in verts for m in range(4) for n in range(m + 1, 4)\n if x[m] < l and x[n] < l]\n return verts, links, plaqs\n\n\ndef on_bdry(x, l):\n return any(c in (0, l) for c in x)\n\n\ndef bdry_link(x, m, l):\n y = add(x, unit(m))\n return any(i != m and x[i] in (0, l) for i in range(4)) and on_bdry(y, l)\n\n\ndef bdry_plaq(x, m, n, l):\n return any(i not in (m, n) and x[i] in (0, l) for i in range(4))\n\n\ndef holonomy(U, x, m, n):\n a = U[(x, m)]\n b = U[(add(x, unit(m)), n)]\n c = qinv(U[(add(x, unit(n)), m)])\n d = qinv(U[(x, n)])\n return qmul(qmul(a, b), qmul(c, d))\n\n\nORDER = [(0, 1), (1, 1), (1, 0), (2, 1), (2, 0), (3, 1), (3, 0), (0, 0)]\n\n\ndef facet_verts(l, i, s):\n return [x for x in itertools.product(range(l + 1), repeat=4)\n if x[i] == s * l]\n\n\ndef facet_links(l, i, s):\n return [(x, m) for x in facet_verts(l, i, s) for m in range(4)\n if m != i and x[m] < l]\n\n\ndef path_hol(eta, l, i, s, x):\n """Holonomy of the path from the facet corner to x, moving first in the\n lowest free direction, then the next, then the last."""\n free = [m for m in range(4) if m != i]\n y = [0, 0, 0, 0]\n y[i] = s * l\n h = ONE\n for m in free:\n for _ in range(x[m]):\n h = qmul(h, eta[(tuple(y), m)])\n y[m] += 1\n return h\n\n\ndef gauged(eta, g, x, m):\n return qmul(qmul(g[x], eta[(x, m)]), qinv(g[add(x, unit(m))]))\n\n\ndef d1(x, y):\n return sum(abs(a - b) for a, b in zip(x, y))\n\n\ndef boundary_gauge(eta, l, rho):\n """Facet gauges glued as in the proof. Returns g and the list of\n observed maxima per stage."""\n g = {}\n done_links = []\n stats = []\n for k, (i, s) in enumerate(ORDER, start=1):\n V = facet_verts(l, i, s)\n g0 = {x: path_hol(eta, l, i, s, x) for x in V}\n loc = max(angle(gauged(eta, g0, x, m)) for (x, m) in facet_links(l, i, s))\n check(f"l={l} facet {k}: coordinate-path gauge <= 2 l rho_s",\n loc <= 2 * l * rho * (1 + mp.mpf(10) ** -30))\n Gam = [x for x in V if x in g]\n if k == 1:\n for x in V:\n g[x] = g0[x]\n else:\n t = {x: qmul(g[x], qinv(g0[x])) for x in Gam}\n x0 = Gam[0]\n a = {x: qlog(qmul(qinv(t[x0]), t[x])) for x in Gam}\n L = 6 * (C[k - 1] * l * rho + 2 * l * rho)\n lip = max((vnorm(vadd(a[x], vscale(-1, a[y]))) / d1(x, y)\n for x in Gam for y in Gam if x != y), default=0)\n check(f"l={l} facet {k}: log of transition is L-Lipschitz",\n lip <= L * (1 + mp.mpf(10) ** -30))\n ta = {}\n for x in V:\n ta[x] = tuple(min(a[y][j] + L * d1(x, y) for y in Gam)\n for j in range(3))\n agree = max(vnorm(vadd(ta[x], vscale(-1, a[x]))) for x in Gam)\n check(f"l={l} facet {k}: McShane extension agrees on Gamma",\n agree < mp.mpf(10) ** -50 * max(rho, mp.mpf(10) ** -40))\n for x in V:\n if x not in g:\n g[x] = qmul(qmul(t[x0], qexp(ta[x])), g0[x])\n done_links += facet_links(l, i, s)\n Mk = max(angle(gauged(eta, g, x, m)) for (x, m) in done_links)\n stats.append(Mk / (l * rho))\n check(f"l={l} after facet {k}: links <= C_{k} l rho_s "\n f"(observed {float(Mk / (l * rho)):.3g} l rho_s)",\n Mk <= C[k] * l * rho * (1 + mp.mpf(10) ** -30))\n return g, stats\n\n\ndef make_boundary(l, rng, amp):\n verts, links, plaqs = box(l)\n gg = {x: haar(rng) for x in verts if on_bdry(x, l)}\n eta = {}\n for (x, m) in links:\n if bdry_link(x, m, l):\n y = add(x, unit(m))\n eta[(x, m)] = qmul(qmul(gg[x], qexp(small(rng, amp))), qinv(gg[y]))\n rho = max(angle(holonomy(eta, x, m, n)) for (x, m, n) in plaqs\n if bdry_plaq(x, m, n, l))\n return eta, rho\n\n\n# ----------------------------------------------------------- the extension\n\ndef make_B(A, l):\n c = mp.mpf(l) / 2\n R0 = mp.mpf(l) / 2\n\n def Ahat(i, base, y):\n """Whitney form on the unit cube of facet i with lower corner base,\n at the boundary point y; returns {direction: coefficient}."""\n free = [m for m in range(4) if m != i]\n t = {m: y[m] - base[m] for m in free}\n out = {}\n for j in free:\n o1, o2 = [m for m in free if m != j]\n acc = (mp.mpf(0),) * 3\n for b1 in (0, 1):\n for b2 in (0, 1):\n e = list(base)\n e[o1] += b1\n e[o2] += b2\n lam = ((t[o1] if b1 else 1 - t[o1]) *\n (t[o2] if b2 else 1 - t[o2]))\n acc = vadd(acc, vscale(lam, A[(tuple(e), j)]))\n out[j] = acc\n return out\n\n def B(cell, x, m):\n """B(e_m) at x, with the formula of the cone cell = (i, sgn, base)."""\n i, sgn, base = cell\n r = sgn * (x[i] - c)\n if r == 0:\n return (mp.mpf(0),) * 3\n y = [c + R0 * (xj - c) / r for xj in x]\n dphi = [R0 * (1 if j == m else 0) / r for j in range(4)]\n if m == i:\n dphi = [dphi[j] - R0 * (x[j] - c) * sgn / r ** 2 for j in range(4)]\n a = Ahat(i, base, y)\n out = (mp.mpf(0),) * 3\n for j, coef in a.items():\n out = vadd(out, vscale(dphi[j], coef))\n return vscale((r / R0) ** 2, out)\n\n def cell_at(x):\n d = [abs(x[j] - c) for j in range(4)]\n i = max(range(4), key=lambda j: d[j])\n sgn = 1 if x[i] > c else -1\n r = d[i]\n y = [c + R0 * (xj - c) / r for xj in x]\n base = []\n for j in range(4):\n if j == i:\n base.append(l if sgn > 0 else 0)\n else:\n base.append(min(int(mp.floor(y[j])), l - 1))\n return (i, sgn, tuple(base))\n\n def breakpoints(x0, m):\n cand = set()\n xm = mp.mpf(x0[m])\n for i in range(4):\n if i == m:\n continue\n di = abs(x0[i] - c)\n for sg in (1, -1):\n cand.add(c + sg * di - xm)\n for k in range(l + 1):\n cand.add(c + (k - c) * di / R0 - xm)\n for j in range(4):\n if j == m or x0[j] == c:\n continue\n for k in range(l + 1):\n if k == c:\n continue\n rt = R0 * (x0[j] - c) / (k - c)\n if rt > 0:\n for sg in (1, -1):\n cand.add(c + sg * rt - xm)\n pts = sorted(s for s in cand if 0 < s < 1)\n out = [mp.mpf(0)]\n for s in pts:\n if s - out[-1] > mp.mpf(10) ** -40:\n out.append(s)\n if 1 - out[-1] > mp.mpf(10) ** -40:\n out.append(mp.mpf(1))\n else:\n out[-1] = mp.mpf(1)\n return out\n\n def transport(x0, m, steps=12):\n bp = breakpoints(x0, m)\n T = ONE\n for s0, s1 in zip(bp, bp[1:]):\n mid = [mp.mpf(v) for v in x0]\n mid[m] += (s0 + s1) / 2\n if all(abs(mid[j] - c) == 0 for j in range(4)):\n continue\n cell = cell_at(mid)\n h = (s1 - s0) / steps\n\n def f(s):\n p = [mp.mpf(v) for v in x0]\n p[m] += s\n return (mp.mpf(0),) + B(cell, p, m)\n\n s = s0\n for _ in range(steps):\n k1 = qmul(T, f(s))\n T2 = tuple(a + h / 2 * b for a, b in zip(T, k1))\n k2 = qmul(T2, f(s + h / 2))\n T3 = tuple(a + h / 2 * b for a, b in zip(T, k2))\n k3 = qmul(T3, f(s + h / 2))\n T4 = tuple(a + h * b for a, b in zip(T, k3))\n k4 = qmul(T4, f(s + h))\n T = tuple(a + h / 6 * (b1 + 2 * b2 + 2 * b3 + b4)\n for a, b1, b2, b3, b4 in zip(T, k1, k2, k3, k4))\n s += h\n n = mp.sqrt(sum(a * a for a in T))\n return tuple(a / n for a in T)\n\n return transport\n\n\ndef full_filling(l, rng, amp):\n verts, links, plaqs = box(l)\n eta, rho = make_boundary(l, rng, amp)\n check(f"l={l} full: hypothesis l^2 rho_s <= eps_0 "\n f"(rho_s = {mp.nstr(rho, 3)})", l * l * rho <= mp.mpf(EPS0.numerator) / EPS0.denominator)\n g, _ = boundary_gauge(eta, l, rho)\n A = {}\n for (x, m) in links:\n if bdry_link(x, m, l):\n A[(x, m)] = qlog(gauged(eta, g, x, m))\n M = max(vnorm(a) for a in A.values())\n check(f"l={l} full: |A| <= C_8 l rho_s", M <= C8 * l * rho)\n curl = 0\n for (x, m, n) in plaqs:\n if bdry_plaq(x, m, n, l):\n v = vadd(vadd(A[(x, m)], A[(add(x, unit(m)), n)]),\n vscale(-1, vadd(A[(add(x, unit(n)), m)], A[(x, n)])))\n curl = max(curl, vnorm(v))\n check(f"l={l} full: |dA| <= rho_s + 8 M^2", curl <= rho + 8 * M * M)\n transport = make_B(A, l)\n V = {(x, m): transport(x, m) for (x, m) in links}\n err = max(angle(qmul(qinv(V[e]), qexp(A[e]))) for e in A)\n check(f"l={l} full: boundary transports equal exp(A_e) "\n f"(error {mp.nstr(err, 3)})", err <= rho * mp.mpf(10) ** -12)\n gext = {x: g.get(x, ONE) for x in verts}\n U = {(x, m): qmul(qmul(qinv(gext[x]), V[(x, m)]), gext[add(x, unit(m))])\n for (x, m) in links}\n berr = max(angle(qmul(qinv(U[e]), eta[e])) for e in eta)\n check(f"l={l} full: filled field equals eta on boundary links",\n berr <= rho * mp.mpf(10) ** -12)\n worst = max(angle(holonomy(U, x, m, n)) for (x, m, n) in plaqs)\n check(f"l={l} full: every plaquette angle <= K rho_s "\n f"(observed {float(worst / rho):.4g} rho_s)", worst <= K * rho)\n inner = [p for p in plaqs if not bdry_plaq(*p, l)]\n check(f"l={l} full: {len(inner)} inner plaquettes checked", len(inner) > 0)\n\n\ndef main():\n exact_checks()\n rng = random.Random(20261030)\n for l in (2, 3, 4):\n for trial in range(2):\n amp = mp.mpf(EPS0.numerator) / EPS0.denominator / (8 * l * l)\n eta, rho = make_boundary(l, rng, amp)\n check(f"l={l} trial {trial}: hypothesis l^2 rho_s <= eps_0",\n l * l * rho <= mp.mpf(EPS0.numerator) / EPS0.denominator)\n big = max(angle(e) for e in eta.values())\n check(f"l={l} trial {trial}: boundary links are not small "\n f"(max angle {float(big):.3g})", big > 1)\n boundary_gauge(eta, l, rho)\n for l in (2, 3):\n amp = mp.mpf(EPS0.numerator) / EPS0.denominator / (8 * l * l)\n full_filling(l, rng, amp)\n n_ok = sum(ok for _, ok in checks)\n print(f"{n_ok} of {len(checks)} checks passed")\n raise SystemExit(0 if n_ok == len(checks) else 1)\n\n\nif __name__ == "__main__":\n main()\n', 'off_chart.py': '"""Checks of the mass off the chart (Theorem thm:offchart of the forest\npaper, Sec. ssec:smallfibres), for G = SU(2) on the periodic lattice of side 4.\n\nThe backgrounds are those of small_field_fibre.py. For a set W of blocks the\nprogram\n\n (k) checks the first step of the proof: if U and U\' agree off A_W, have the\n same cut-off averages and all plaquettes at most kappa and kappa\', then\n delta(U_e, U\'_e) <= 92.3 max(kappa, kappa\') on every link of A_W. The\n points U\' are found by a search on the fibre: random moves of the links\n of A_W other than the path links, the path links then solved from the\n constraints by Newton\'s method, followed by descent of the action Q on\n the fibre; the inequality is checked at every iterate;\n (l) checks the covariance comparison |Cov_mu(F,G) - Cov_{mu(.|A)}(F,G)|\n <= 6 eps |F|_inf |G|_inf, eps = mu(A^c), in exact arithmetic on random\n finite laws;\n (m) checks the arithmetic of the constants of the theorem exactly, and\n the least beta_W with q_kappa(beta_W) < 1 at kappa = 1.4e-14.\n\nThe search of (k) is a floating-point computation at fields far larger than\nthose of the theorem; it is not a certificate.\n\nUsage: python3 off_chart.py\n"""\n\nimport math\nimport random\nfrom fractions import Fraction as Fr\n\nimport numpy as np\n\nimport small_field_fibre as S\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append((name, bool(ok)))\n print(("PASS " if ok else "FAIL ") + name)\n\n\ndef setup(eps, W, seed):\n rng = np.random.default_rng(seed)\n U = S.make_field(eps, rng)\n kappa = max(S.dist(S.hol(U, p), S.I2) for p in S.PLAQ)\n Wset = set(W)\n var = [(x, mu) for x in S.SITES for mu in range(S.DIM)\n if not S.is_tree(x, mu) and S.blk(x) in Wset]\n cons = [(y, mu) for y in W for mu in range(S.DIM)]\n path = {k: (S.add(tuple(2 * c for c in k[0]), S.e(k[1])), k[1]) for k in cons}\n free = [l for l in var if l not in set(path.values())]\n V0 = {k: S.vsharp(U, *k)[0] for k in cons}\n varset = set(var)\n plist = [p for p in S.PLAQ if any(l in varset for l in S.plinks(p))]\n return dict(U=U, kappa=kappa, var=var, cons=cons, path=path, free=free,\n V0=V0, plist=plist, rng=rng)\n\n\ndef solve_paths(st, Uf):\n """Solve V^sharp_k(Uf) = V0_k by moving the path link d_k, which enters\n only V_k. Returns False if Newton\'s method fails or leaves the branch."""\n for k in st["cons"]:\n d = st["path"][k]\n for _ in range(30):\n try:\n c = S.logm(st["V0"][k].conj().T @ S.vsharp(Uf, *k)[0])\n except AssertionError:\n return False\n if np.max(np.abs(c)) < 1e-13:\n break\n J = np.zeros((3, 3))\n base = Uf[d]\n t = 1e-6\n for a in range(3):\n da = np.zeros(3)\n da[a] = t\n Uf[d] = base @ S.expm(da)\n cp = S.logm(st["V0"][k].conj().T @ S.vsharp(Uf, *k)[0])\n Uf[d] = base @ S.expm(-da)\n cm = S.logm(st["V0"][k].conj().T @ S.vsharp(Uf, *k)[0])\n J[:, a] = (cp - cm) / (2 * t)\n Uf[d] = base @ S.expm(-np.linalg.solve(J, c))\n else:\n return False\n return True\n\n\ndef Q(st, Uf):\n return sum(S.dist(S.hol(Uf, p), S.I2) ** 2 for p in st["plist"])\n\n\ndef gradQ(st, Uf):\n """Left-trivialised gradient of Q in the free links: dQ(xi) =\n -2 sum_p Re Tr(D_p(xi) U_p)."""\n g = {l: np.zeros(3) for l in st["free"]}\n for p in st["plist"]:\n Up = S.hol(Uf, p)\n w = np.array([-2 * np.real(np.trace(S.TAU[a] @ Up)) for a in range(3)])\n for i, l in enumerate(S.plinks(p)):\n if l in g:\n g[l] += S.dmaps(Uf, p)[i].T @ w\n return g\n\n\ndef measure(st, Uf):\n kp = max(S.dist(S.hol(Uf, p), S.I2) for p in S.PLAQ)\n dm = max(S.dist(st["U"][l], Uf[l]) for l in st["var"])\n return kp, dm\n\n\ndef run(eps, W, seed, sizes, steps, label):\n st = setup(eps, W, seed)\n rng = st["rng"]\n kappa = st["kappa"]\n tag = f"eps={eps:g}, |W|={len(W)}, kappa={kappa:.3e}"\n print(f"-- {label}: {tag}")\n worst, npts, final = 0.0, 0, []\n ok = True\n for a in sizes:\n Uf = dict(st["U"])\n for l in st["free"]:\n Uf[l] = st["U"][l] @ S.expm(rng.normal(size=3) * a / np.sqrt(3))\n if not solve_paths(st, Uf):\n print(f" start of size {a}: outside the small-field branch, skipped")\n continue\n q = Q(st, Uf)\n for _ in range(steps):\n kp, dm = measure(st, Uf)\n npts += 1\n r = dm / max(kappa, kp)\n worst = max(worst, r)\n ok &= dm <= 92.3 * max(kappa, kp)\n g = gradQ(st, Uf)\n t = 0.05\n while t > 1e-6:\n Un = dict(Uf)\n for l in st["free"]:\n Un[l] = Uf[l] @ S.expm(-t * g[l])\n if solve_paths(st, Un) and Q(st, Un) < q:\n Uf, q = Un, Q(st, Un)\n break\n t /= 2\n else:\n break\n kp, dm = measure(st, Uf)\n final.append((a, kp, dm))\n ok &= dm <= 92.3 * max(kappa, kp)\n npts += 1\n worst = max(worst, dm / max(kappa, kp))\n for a, kp, dm in final:\n print(f" start of size {a}: final kappa\' = {kp:.3e}, max delta(U_e, U\'_e) = {dm:.3e}")\n check(f"(k) delta(U_e, U\'_e) <= 92.3 max(kappa, kappa\') at {npts} points of the fibre, "\n f"largest ratio {worst:.2f} ({tag})", ok and npts > 0)\n return worst\n\n\ndef covariance_check(trials=300, seed=11):\n rnd = random.Random(seed)\n ok = True\n for _ in range(trials):\n n = rnd.randint(3, 9)\n w = [Fr(rnd.randint(1, 50)) for _ in range(n)]\n Z = sum(w)\n p = [x / Z for x in w]\n F = [Fr(rnd.randint(-20, 20), 7) for _ in range(n)]\n G = [Fr(rnd.randint(-20, 20), 5) for _ in range(n)]\n A = [rnd.random() < 0.8 for _ in range(n)]\n if not any(A):\n continue\n pa = sum(pi for pi, inA in zip(p, A) if inA)\n e = 1 - pa\n E = lambda f, m: sum(mi * fi for mi, fi in zip(m, f))\n q = [pi / pa if inA else Fr(0) for pi, inA in zip(p, A)]\n cov = lambda m: E([f * g for f, g in zip(F, G)], m) - E(F, m) * E(G, m)\n lhs = abs(cov(p) - cov(q))\n ok &= lhs <= 6 * e * max(abs(x) for x in F) * max(abs(x) for x in G)\n check(f"(l) |Cov_mu - Cov_mu(.|A)| <= 6 mu(A^c) |F|_inf |G|_inf on {trials} random finite laws", ok)\n\n\ndef constants():\n check("(m) 16 pi <= 50.3, 3 + 3 = 6 <= 92.3 and 21 + 21 + 50.3 = 92.3",\n 16 * math.pi <= 50.3 and 21 + 21 + Fr(503, 10) == Fr(923, 10))\n check("(m) (pi/3) 92.3 <= 96.7 and 1280 * 96.7 <= 1.24e5",\n math.pi / 3 * 92.3 <= 96.7 and 1280 * Fr(967, 10) <= 124000)\n check("(m) 92.3 kappa <= 1 and <= rho_G when kappa <= 1e-8 rho_G", 92.3e-8 <= 1)\n check("(m) blocks at distance at most two: 5^4 = 625, and 625 * 16 = 10^4", 5 ** 4 * 16 == 10 ** 4)\n check("(m) half the diameter of SU(2) is sqrt(2) pi / 2 <= 2.23 and 6 * 2.23^2 < 30",\n math.sqrt(2) * math.pi / 2 <= 2.23 and 6 * Fr(223, 100) ** 2 < 30)\n check("(m) kappa + 6 s <= 1e-8 with s = 1.24e5 kappa forces kappa <= 1.4e-14",\n Fr(1, 10 ** 8) / (1 + 6 * 124000) <= Fr(14, 10 ** 15))\n C0 = 0.5 + 2 / 3 * math.log(24 * math.pi ** 3)\n k = 1.4e-14\n b = 1.0\n while b * k * k <= 96 * (math.log(b) + C0):\n b *= 1.01\n check(f"(m) q_kappa(beta) < 1 at kappa = 1.4e-14 needs beta > {b:.2e} > 1e31", b > 1e31)\n\n\nif __name__ == "__main__":\n constants()\n covariance_check()\n blocks = S.BLOCKS\n two = [blocks[0], blocks[1]]\n eight = [y for y in blocks if sum(y) % 2 == 0]\n worst = []\n for eps, W, seed, sizes, steps, lab in (\n (1e-3, two, 21, (0.02, 0.05, 0.1, 0.2), 25, "two blocks"),\n (1e-2, two, 22, (0.02, 0.05, 0.1, 0.2), 25, "two blocks"),\n (1e-3, eight, 23, (0.05, 0.1), 15, "eight blocks")):\n worst.append(run(eps, W, seed, sizes, steps, lab))\n print(f"largest ratio delta / max(kappa, kappa\') observed: {max(worst):.2f}")\n n_ok = sum(ok for _, ok in checks)\n print(f"{n_ok} of {len(checks)} checks passed")\n', 'path_blocks.py': '"""Checks for the path blocks: the anchored cube, the coercivity bound 224 on\ngroup-valued fields, the coarse curvature and reconstruction bounds, and the\nthin-path ratio.\n\nParts:\n (A) anchored cube: the Laplacian of {0,1}^3 with the vertex 0 deleted has\n characteristic polynomial (x-3)(x^2-6x+2)(x-2)^2(x-4)^2 (exact), so its\n eigenvalues are 3, 3 +- sqrt 7, and 2, 4 twice; the least, 3 - sqrt 7,\n exceeds 1/3.\n (B) SU(2) fields in the tree gauge on the periodic lattice of side 4:\n D_v^2 <= 224 Q, Q_1(V) <= 4 Q, Q(R(v)) = 4 Q_1(v), Q <= 8 Q_1 + 48 D_v^2\n (floating point, random fields at five scales).\n (C) thin paths: Q / Q_k = s sin^2(pi/(2s)) for s = 2, 4, ..., 64, from the\n s/2 changed links with six plaquettes each and the six coarse plaquettes\n of the one nontrivial coarse link.\n (D) slice windings: three covariant continuous maps of eight slice links\n (u_1 and alternating products u_a u_b^-1 u_c ...) satisfy F(g u g^-1) =\n g F(u) g^-1 and F(g u) = g F(u), and the degrees of their coordinate loops\n add up to one; the normalised quaternion mean of the eight links, which\n treats them alike, takes values 2 apart at fields arbitrarily close to\n the field with u_t = -I on four links and I on the others.\n (E) the same for SU(3) on its maximal torus: for covariant continuous maps of\n six slice links the integer matrices W_t on H_1 of the torus add up to the\n identity.\n (F) the cut-off average V# = V^p exp(chi/16 sum_x log(V^p^-1 P_x)) on SU(2),\n rho = 1, c = pi/3: covariance, differential at I equal to the block\n average, the bounds 896, 56 c^2, 448 + 896 c^2, 8 + 2688 c^2 on random\n fields at five scales, slice windings 1 at the path and 0 elsewhere,\n and the coarse link e^{X/8} of a single small link e^X.\n (G) torus-valued fields (random and smooth, under random gauge\n transformations) on the lattice of side 8, two steps with the tree gauge\n restored between them: the cut-off is inactive, the coarse plaquette\n angles are the means of the sixteen 2x2 fluxes, the L1 norm drops by at\n least 4, the L2 norm does not increase, the maximum grows by at most 4,\n and Q_2 <= 1.001 Q when eta_0 A <= (rho/12)^2.\n (H) SU(2) fields of small noncommuting curvature (random and smooth, under\n random SU(2) gauge transformations) on the lattice of side 8, two steps:\n the cut-off is inactive, the coarse plaquette logarithm is the mean of the\n sixteen 2x2 square logarithms up to 3.2 r_P^2 with r_P <= 28.26 eta, and\n the growth bounds of sqrt E, A and eta of the nonabelian step hold.\n (I) large fields under the SU(2) Wilson measure: on the torus of side 8 a\n plaquette lies in exactly four unit cubes, a cube has 24 plaquettes and\n 80 neighbours, Z_{y,mu} has 24 cubes and a cube lies in Z_{y,mu} for at\n most eight coarse links; the constants C_0, 4 8 4 24 144 <= 4.5e5 and\n 8 b_0 = 11/(3 pi^2) < 4/3; the link-angle bound 1/(24 pi^3 beta^{3/2}) and\n the one-link tail p = v_* e^{-3 beta} by quadrature, with the cap\n probability decreasing in the distance of the centre and increasing in\n kappa; the staple sum -4I of the frustrated exterior on a lattice and the\n conditional probability of p_0 being bad, even for rho = 2.5; and on random SU(2) fields with\n localised large links, chi = 1 at every coarse link whose 24 cubes are\n good for rho = 1/12.\n (J) defects across scales: SU(2) fields of small curvature with a localised\n large link on the lattice of side 8, one step: every plaquette outside\n the propagated defect set B_j (coarse plaquettes whose box 2y+[0,4]^4\n meets B_{j-1}) has |Theta| <= eta_j with eta_{j+1} = 4(1+647 eta_j)eta_j,\n every plaquette of B_j lies within l-infinity distance 3(2^j-1) of B_0,\n and the energy outside the defects obeys the bound of the theorem.\n (K) effective forms uniformly in the scale: in exact integer arithmetic on\n periodic lattices (d = 4 with L = 2, 4; d = 2 with L = 8; d = 3 with\n L = 4), the Whitney extension with nodes at the block centres has k-fold\n averages T u with T = tau^(x d), tau = (1/8, 3/4, 1/8), plaquette energy\n at most Q_k(u), and zero curvature on gradients; the symbol of tau is at\n least 1/2, against 1/L with the coarse sites as nodes.\nRun: python3 path_blocks.py. Needs numpy."""\nimport itertools, math\nimport numpy as np\n\nok = []\ndef check(name, cond):\n ok.append(bool(cond)); print((\'ok \' if cond else \'FAIL\'), name)\n\n# (A)\nV = [a for a in itertools.product(range(2), repeat=3) if any(a)]\nL0 = np.zeros((7, 7), dtype=int)\nfor i, a in enumerate(V):\n L0[i, i] = 3\n for j, b in enumerate(V):\n if sum(x != y for x, y in zip(a, b)) == 1: L0[i, j] = -1\nev = np.sort(np.linalg.eigvalsh(L0))\nwant = np.sort([3, 3 + math.sqrt(7), 3 - math.sqrt(7), 2, 2, 4, 4])\ncheck(\'(A) spectrum of the grounded cube Laplacian is 3, 3 +- sqrt7, 2, 2, 4, 4\',\n np.allclose(ev, want))\n# exact: det(L0 - 3) in integers equals the value of (t^3-7t)(t^2-6t+8)^2 at t=0... use\n# the integer characteristic polynomial via Faddeev-LeVerrier\ndef charpoly(M):\n n = len(M); M = [[int(x) for x in r] for r in M]\n from fractions import Fraction as F\n c = [F(1)]; Mk = [[F(0)] * n for _ in range(n)]\n I = [[F(int(i == j)) for j in range(n)] for i in range(n)]\n A = [[F(x) for x in r] for r in M]\n for k in range(1, n + 1):\n Mk = [[sum(A[i][l] * Mk[l][j] for l in range(n)) + c[-1] * I[i][j] for j in range(n)] for i in range(n)]\n AM = [[sum(A[i][l] * Mk[l][j] for l in range(n)) for j in range(n)] for i in range(n)]\n c.append(-sum(AM[i][i] for i in range(n)) / k)\n return [int(x) for x in c]\n# expected (x-3)(x^2-6x+2)(x-2)^2(x-4)^2\ndef mul(p, q):\n r = [0] * (len(p) + len(q) - 1)\n for i, a in enumerate(p):\n for j, b in enumerate(q): r[i + j] += a * b\n return r\nexp = [1]\nfor f in ([1, -3], [1, -6, 2], [1, -2], [1, -2], [1, -4], [1, -4]): exp = mul(exp, f)\ncheck(\'(A) exact characteristic polynomial (x-3)(x^2-6x+2)(x-2)^2(x-4)^2\', charpoly(L0) == exp)\ncheck(\'(A) 3 - sqrt7 > 1/3, i.e. 64 > 63 after squaring 8/3 > sqrt7\', 64 > 9 * 7)\n\n# (B)\nrng = np.random.default_rng(7)\nS = 4; d = 4; E = np.eye(d, dtype=int)\nsig = np.array([[[0, 1], [1, 0]], [[0, -1j], [1j, 0]], [[1, 0], [0, -1]]])\ndef su2(a):\n n = np.linalg.norm(a)\n if n == 0: return np.eye(2, dtype=complex)\n return math.cos(n) * np.eye(2) + math.sin(n) / n * 1j * np.tensordot(a, sig, 1)\ndef tree(o, mu): return o[mu] == 0 and all(o[n] == 0 for n in range(mu + 1, d))\nsites = list(itertools.product(range(S), repeat=d))\nsh = lambda x, mu, k=1: tuple((np.array(x) + k * E[mu]) % S)\ndef hs2(A): return float(np.sum(np.abs(A) ** 2))\ndef energies(U, Sz=S, step=1):\n Q = 0.0\n pts = [x for x in itertools.product(range(0, Sz, step), repeat=d)]\n for x in pts:\n for mu in range(d):\n for nu in range(mu + 1, d):\n P = U[(x, mu)] @ U[(tuple((np.array(x) + step * E[mu]) % Sz), nu)] @ \\\n U[(tuple((np.array(x) + step * E[nu]) % Sz), mu)].conj().T @ U[(x, nu)].conj().T\n Q += hs2(P - np.eye(2))\n return Q\nworst = [0, 0, 0, 0]\nfor sc in [0.05, 0.3, 1.0, 2.0, 6.0]:\n for rep in range(2):\n U = {}\n for x in sites:\n o = [c % 2 for c in x]\n for mu in range(d):\n U[(x, mu)] = np.eye(2, dtype=complex) if tree(o, mu) else su2(sc * rng.normal(size=3))\n Q = energies(U)\n v = {(y, mu): U[(sh(y, mu), mu)] for y in itertools.product(range(0, S, 2), repeat=d) for mu in range(d)}\n R, D = {}, 0.0\n for x in sites:\n o = [c % 2 for c in x]; y = tuple(c // 2 * 2 for c in x)\n for mu in range(d):\n R[(x, mu)] = v[(y, mu)] if o[mu] == 1 else np.eye(2, dtype=complex)\n D += hs2(U[(x, mu)] - R[(x, mu)])\n # coarse plaquettes: holonomy of 2x2 squares at even sites (coarse torus side 2 counts each twice per plane)\n Vc = {}\n for y in itertools.product(range(0, S, 2), repeat=d):\n for mu in range(d): Vc[(y, mu)] = U[(y, mu)] @ U[(sh(y, mu), mu)]\n Q1 = energies(Vc, S, 2)\n QR = energies(R)\n worst[0] = max(worst[0], D / Q); worst[1] = max(worst[1], Q1 / Q)\n worst[2] = max(worst[2], abs(QR - 4 * Q1) / max(1, Q1)); worst[3] = max(worst[3], Q / (8 * Q1 + 48 * D))\nprint(\' max D^2/Q = %.4f, max Q_1/Q = %.4f, max |Q(R)-4Q_1| = %.2e, max Q/(8Q_1+48D^2) = %.4f\' % tuple(worst))\ncheck(\'(B) D_v^2 <= 224 Q on random SU(2) fields\', worst[0] <= 224)\ncheck(\'(B) Q_1(V) <= 4 Q\', worst[1] <= 4)\ncheck(\'(B) Q(R(v)) = 4 Q_1(v)\', worst[2] < 1e-9)\ncheck(\'(B) Q <= 8 Q_1 + 48 D_v^2\', worst[3] <= 1)\n\n# (C)\nT = np.diag([1j * math.pi / 2, -1j * math.pi / 2])\ndef expm(Hd): return np.diag(np.exp(np.diag(Hd)))\ngood = True\nfor k in range(1, 7):\n s = 2 ** k; n = 3 * s\n ch = expm(2 * T / s)\n # plaquettes containing a changed link (j,0,0,0), direction 0, j odd < s: six each, distinct\n Qf = 0.0\n for j in range(1, s, 2):\n for nu in range(1, 4):\n # plaquette at (j,0,..) and at (j,0,..)-e_nu in the plane {0,nu}\n Qf += 2 * hs2(ch - np.eye(2))\n Qk = 6 * hs2(expm(T) - np.eye(2))\n r = Qf / Qk; want = s * math.sin(math.pi / (2 * s)) ** 2\n good &= abs(r - want) < 1e-12 and r <= math.pi ** 2 / (4 * s) + 1e-15\n print(\' s = %3d: Q/Q_k = %.6f, s sin^2(pi/2s) = %.6f\' % (s, r, want))\ncheck(\'(C) thin-path ratio s sin^2(pi/(2s)) <= pi^2/(4s) for s = 2..64\', good)\n\n# (D)\nX = np.array([[1j, 0], [0, -1j]])\ndef ex(th): return np.diag([np.exp(1j * th), np.exp(-1j * th)])\ndef angle(A): return math.atan2(A[0, 0].imag, A[0, 0].real)\ndef degree(F, t, n=8, N=400):\n tot, prev = 0.0, None\n for k in range(N + 1):\n u = [np.eye(2, dtype=complex)] * n; u = list(u); u[t] = ex(2 * math.pi * k / N)\n a = angle(F(u))\n if prev is not None:\n d = a - prev; d -= 2 * math.pi * round(d / (2 * math.pi)); tot += d\n prev = a\n return round(tot / (2 * math.pi))\ninv = lambda A: A.conj().T\nmaps = {\'path map u_1\': lambda u: u[0],\n \'u_1 u_2^-1 u_3\': lambda u: u[0] @ inv(u[1]) @ u[2],\n \'u_4 u_7^-1 u_2 u_5^-1 u_8\': lambda u: u[3] @ inv(u[6]) @ u[1] @ inv(u[4]) @ u[7]}\nrng = np.random.default_rng(7)\ndef haar():\n q = rng.normal(size=4); q /= np.linalg.norm(q)\n return np.array([[q[0] + 1j * q[1], q[2] + 1j * q[3]], [-q[2] + 1j * q[3], q[0] - 1j * q[1]]])\ngood = True\nfor F in maps.values():\n for _ in range(20):\n u = [haar() for _ in range(8)]; g = haar()\n good &= np.allclose(F([g @ a @ inv(g) for a in u]), g @ F(u) @ inv(g))\n good &= np.allclose(F([g @ a for a in u]), g @ F(u))\ncheck(\'(D) the three maps are covariant on slice fields\', good)\ngood = True\nfor name, F in maps.items():\n w = [degree(F, t) for t in range(8)]\n print(\' %-30s w = %s\' % (name, w)); good &= sum(w) == 1\ncheck(\'(D) slice windings add up to one for covariant continuous maps\', good)\ndef qmean(u):\n q = sum(u) / len(u); r = math.sqrt(abs(np.linalg.det(q)))\n return q / r\neps = 1e-6\nY = np.array([[0, 1], [-1, 0]], dtype=complex)\ndef near(Xd):\n return [ex(math.pi) @ (np.eye(2) * math.cos(eps) + Xd * math.sin(eps))] * 4 + [np.eye(2, dtype=complex)] * 4\njump = np.linalg.norm(qmean(near(X)) - qmean(near(Y)))\nprint(\' quaternion mean at fields within %g of (-I)^4 I^4 in two directions differs by %.4f\' % (eps, jump))\ncheck(\'(D) the symmetric quaternion mean jumps by 2 near (-I,...,-I,I,...,I)\', abs(jump - 2) < 1e-4)\n# (E)\ndef tor3(a, b): return np.diag([np.exp(1j * a), np.exp(1j * b), np.exp(-1j * (a + b))])\ndef wind(vals):\n tot = 0.0\n for v0, v1 in zip(vals, vals[1:]):\n d = math.atan2((v1 / v0).imag, (v1 / v0).real); tot += d\n return round(tot / (2 * math.pi))\ndef wmatrix(F, t, n=6, N=400):\n W = np.zeros((2, 2), dtype=int)\n for j in range(2):\n d0, d1 = [], []\n for k in range(N + 1):\n u = [np.eye(3, dtype=complex) for _ in range(n)]\n th = 2 * math.pi * k / N\n u[t] = tor3(th, 0) if j == 0 else tor3(0, th)\n R = F(u); d0.append(R[0, 0]); d1.append(R[1, 1])\n W[0, j], W[1, j] = wind(d0), wind(d1)\n return W\ndef haar3():\n z = rng.normal(size=(3, 3)) + 1j * rng.normal(size=(3, 3))\n q, r = np.linalg.qr(z); q = q @ np.diag(np.diag(r) / abs(np.diag(r)))\n return q / np.linalg.det(q) ** (1 / 3)\nmaps3 = {\'u_1\': lambda u: u[0], \'u_1 u_2^-1 u_3\': lambda u: u[0] @ inv(u[1]) @ u[2],\n \'u_6 u_4^-1 u_5 u_2^-1 u_3\': lambda u: u[5] @ inv(u[3]) @ u[4] @ inv(u[1]) @ u[2]}\ngood = True\nfor F in maps3.values():\n for _ in range(10):\n u = [haar3() for _ in range(6)]; g = haar3()\n good &= np.allclose(F([g @ a @ inv(g) for a in u]), g @ F(u) @ inv(g))\n good &= np.allclose(F([g @ a for a in u]), g @ F(u))\ncheck(\'(E) the three SU(3) maps are covariant on slice fields\', good)\ngood = True\nfor name, F in maps3.items():\n S = sum(wmatrix(F, t) for t in range(6))\n print(\' %-26s sum of W_t = %s\' % (name, S.tolist())); good &= (S == np.eye(2, dtype=int)).all()\ncheck(\'(E) for SU(3) the torus matrices W_t add up to the identity\', good)\n# (F)\nSd = 4; I2 = np.eye(2, dtype=complex); c = math.pi / 3; rho = 1.0\nshf = lambda x, mu, k=1: tuple((np.array(x) + k * E[mu]) % Sd)\ndef slog(g): # principal logarithm of SU(2) near I\n n = math.acos(max(-1.0, min(1.0, g[0, 0].real / 2 + g[1, 1].real / 2)))\n A = (g - g.conj().T) / 2\n return A if n < 1e-12 else n / math.sin(n) * A\ndef sexp(Z):\n n = math.sqrt(hs2(Z) / 2)\n return I2 * math.cos(n) + (Z if n < 1e-12 else math.sin(n) / n * Z)\ndef phi(t): return 1.0 if t <= 0.5 else (0.0 if t >= 1 else 2 * (1 - t))\nblk = list(itertools.product(range(2), repeat=d))\ndef sharp(U, y, mu):\n P = [U.get((tuple((np.array(y) + o) % Sd), mu), I2) @\n U.get((shf(tuple((np.array(y) + o) % Sd), mu), mu), I2) for o in blk]\n v = [inv(P[0]) @ p for p in P]\n m = max(math.sqrt(hs2(w - I2)) for w in v); chi = phi(m / rho)\n M = I2 if chi == 0 else sexp(chi * sum(slog(w) for w in v) / 16)\n return P[0] @ M, P[0], M, P\nevens = list(itertools.product(range(0, Sd, 2), repeat=d))\ndef field(sc):\n U = {}\n for x in sites:\n o = [q % 2 for q in x]\n for mu in range(d):\n U[(x, mu)] = I2 if tree(o, mu) else su2(sc * rng.normal(size=3))\n return U\n# covariance under the gauge transformations constant on blocks\ngood = True\nfor sc in [0.05, 0.3, 2.0]:\n U = field(sc); h = {y: haar() for y in evens}\n hb = lambda x: h[tuple(q // 2 * 2 for q in x)]\n Uh = {(x, mu): hb(x) @ U[(x, mu)] @ inv(hb(shf(x, mu))) for (x, mu) in U}\n for y in evens:\n for mu in range(d):\n good &= np.allclose(sharp(Uh, y, mu)[0], h[y] @ sharp(U, y, mu)[0] @ inv(h[shf(y, mu, 2)]))\ncheck(\'(F) the cut-off average is covariant under block gauge transformations\', good)\n# linearisation: the block average\nt = 1e-6; err = 0.0\nfor rep in range(3):\n a = {}\n for x in sites:\n o = [q % 2 for q in x]\n for mu in range(d):\n a[(x, mu)] = np.zeros(3) if tree(o, mu) else rng.normal(size=3)\n U = {k: su2(t * a[k]) for k in a}\n for y in evens:\n for mu in range(d):\n avg = sum(a[(tuple((np.array(y) + o) % Sd), mu)] + a[(shf(tuple((np.array(y) + o) % Sd), mu), mu)]\n for o in blk) / 16\n lin = (sharp(U, y, mu)[0] - I2) / t\n err = max(err, np.abs(lin - 1j * np.tensordot(avg, sig, 1)).max())\nprint(\' max |(V#(e^{t phi}) - I)/t - V(phi)| at t = 1e-6: %.2e\' % err)\ncheck(\'(F) the differential of the cut-off average at I is the block average\', err < 1e-4)\n# bounds for all fields\nworst = [0, 0, 0, 0]\nfor sc in [0.05, 0.3, 1.0, 2.0, 6.0]:\n for rep in range(2):\n U = field(sc); Q = energies(U, Sd)\n Vs, sP, sM = {}, 0.0, 0.0\n for y in evens:\n for mu in range(d):\n V, P0, M, P = sharp(U, y, mu); Vs[(y, mu)] = V\n sP += sum(hs2(p - P0) for p in P); sM += hs2(M - I2)\n D = 0.0\n for x in sites:\n o = [q % 2 for q in x]; y = tuple(q // 2 * 2 for q in x)\n for mu in range(d):\n D += hs2(U[(x, mu)] - (Vs[(y, mu)] if o[mu] == 1 else I2))\n Q1 = energies(Vs, Sd, 2)\n worst = [max(worst[0], sP / Q), max(worst[1], sM / Q), max(worst[2], D / Q), max(worst[3], Q1 / Q)]\nprint(\' max sum d(P_x,P_2y)^2/Q = %.3f, sum d(M,I)^2/Q = %.4f, D^2/Q = %.3f, Q_1/Q = %.3f\' % tuple(worst))\ncheck(\'(F) sum of d(P_x, V^p)^2 <= 896 Q\', worst[0] <= 896)\ncheck(\'(F) sum of d(V#, V^p)^2 <= 56 c^2 Q, c = pi/3\', worst[1] <= 56 * c * c)\ncheck(\'(F) D_{V#}^2 <= (448 + 896 c^2) Q\', worst[2] <= 448 + 896 * c * c)\ncheck(\'(F) Q_1(V#) <= (8 + 2688 c^2) Q\', worst[3] <= 8 + 2688 * c * c)\n# slice windings: the identity at the path, zero elsewhere\ntrans = [a for a in itertools.product(range(2), repeat=3)]\ndef Fsharp(u):\n U = {((1,) + a, 0): u[i] for i, a in enumerate(trans)}\n return sharp(U, (0, 0, 0, 0), 0)[0]\nw = [degree(Fsharp, t) for t in range(8)]\nprint(\' slice windings of the cut-off average: %s\' % w)\ncheck(\'(F) slice windings of the cut-off average are 1 at the path and 0 elsewhere\', w == [1] + [0] * 7)\n# one link e^X on the straight path or at another transverse position gives e^{X/8}\ngood = True\nfor a in trans:\n for th in [0.05, 0.15]:\n X = th * np.array([[1j, 0], [0, -1j]])\n V = sharp({((1,) + a, 0): sexp(X)}, (0, 0, 0, 0), 0)[0]\n good &= np.allclose(V, sexp(X / 8))\ncheck(\'(F) one small link e^X at any transverse position gives the coarse link e^{X/8}\', good)\n# (G)\ndef tor(t): return np.diag([np.exp(1j * t), np.exp(-1j * t)])\ndef ang(g): return math.atan2(g[0, 0].imag, g[0, 0].real)\ndef shz(x, mu, Sz, k=1): return tuple((np.array(x) + k * E[mu]) % Sz)\ndef gfix(U, Sz):\n h = {}\n for y in itertools.product(range(0, Sz, 2), repeat=d):\n for o in sorted(blk, key=sum):\n x = tuple((np.array(y) + o) % Sz)\n if not any(o): h[x] = I2; continue\n nu = max(i for i in range(d) if o[i]); p = list(o); p[nu] = 0\n xp = tuple((np.array(y) + p) % Sz); h[x] = h[xp] @ U[(xp, nu)]\n return {(x, mu): h[x] @ U[(x, mu)] @ inv(h[shz(x, mu, Sz)]) for (x, mu) in U}\ndef sharpz(U, y, mu, Sz):\n P = []\n for o in blk:\n x = tuple((np.array(y) + o) % Sz); P.append(U[(x, mu)] @ U[(shz(x, mu, Sz), mu)])\n v = [inv(P[0]) @ p for p in P]\n m = max(math.sqrt(hs2(w - I2)) for w in v); chi = phi(m / rho)\n M = I2 if chi == 0 else sexp(chi * sum(slog(w) for w in v) / 16)\n return P[0] @ M, chi\ndef plaq(U, x, mu, nu, Sz):\n return U[(x, mu)] @ U[(shz(x, mu, Sz), nu)] @ inv(U[(shz(x, nu, Sz), mu)]) @ inv(U[(x, nu)])\ndef angles(U, Sz):\n return {(x, mu, nu): ang(plaq(U, x, mu, nu, Sz)) for x in itertools.product(range(Sz), repeat=d)\n for mu in range(d) for nu in range(mu + 1, d)}\ndef step(U, Sz):\n U = gfix(U, Sz); W, cmin = {}, 1.0\n for y in itertools.product(range(0, Sz, 2), repeat=d):\n for mu in range(d):\n W[(tuple(q // 2 for q in y), mu)], c = sharpz(U, y, mu, Sz); cmin = min(cmin, c)\n return W, cmin\nSz = 8; eta_G = rho / 12\ngood_formula, good_tree, rows = True, True, []\ncph = rng.uniform(0, 2 * math.pi, size=(d, d))\nfor eps in [1e-5, 3e-3, 0.004]:\n U = {}\n g = {x: tor(rng.uniform(0, 2 * math.pi)) for x in itertools.product(range(Sz), repeat=d)}\n for x in itertools.product(range(Sz), repeat=d):\n for mu in range(d):\n a = eps * rng.normal() if eps != 0.004 else \\\n eps * sum(math.sin(2 * math.pi * x[n] / Sz + cph[mu, n]) for n in range(d) if n != mu)\n U[(x, mu)] = g[x] @ tor(a) @ inv(g[shz(x, mu, Sz)])\n Th = angles(U, Sz); Q0 = sum(8 * math.sin(t / 2) ** 2 for t in Th.values())\n A = sum(math.sqrt(2) * abs(t) for t in Th.values()); eta0 = max(math.sqrt(2) * abs(t) for t in Th.values())\n cur, cs = U, Sz\n for j in range(2):\n Ug = gfix(cur, cs)\n good_tree &= all(np.allclose(Ug[(tuple((np.array(y) + o) % cs), mu)], I2)\n for y in itertools.product(range(0, cs, 2), repeat=d) for o in blk for mu in range(d)\n if tree(list(o), mu))\n Tc = angles(cur, cs); mx = max(math.sqrt(2) * abs(t) for t in Tc.values())\n nxt, cmin = step(cur, cs); ns = cs // 2; Tn = angles(nxt, ns)\n err = 0.0\n if mx <= eta_G:\n for (y, mu, nu), t in Tn.items():\n f = 0.0\n for o in blk:\n x = tuple((2 * np.array(y) + o) % cs)\n for a, b in [(0, 0), (1, 0), (0, 1), (1, 1)]:\n z = tuple((np.array(x) + a * E[mu] + b * E[nu]) % cs); f += Tc[(z, mu, nu)]\n err = max(err, abs(t - f / 16))\n good_formula &= err < 1e-9 and cmin == 1.0\n L1c = sum(abs(t) for t in Tc.values()); L1n = sum(abs(t) for t in Tn.values())\n L2c = sum(t * t for t in Tc.values()); L2n = sum(t * t for t in Tn.values())\n mxn = max(abs(t) for t in Tn.values())\n rows.append((eps, j, mx <= eta_G, cmin, err, L1n / L1c, L2n / L2c, mxn / max(abs(t) for t in Tc.values())))\n cur, cs = nxt, ns\n Qk = sum(8 * math.sin(t / 2) ** 2 for t in angles(cur, cs).values())\n rows.append((\'Q\', eps, eta0 * A <= eta_G ** 2, Qk / Q0))\nfor r in rows:\n if r[0] == \'Q\': print(\' eps = %g: eta0*A <= eta_G^2: %s, Q_2/Q = %.4f\' % r[1:])\n else: print(\' eps = %g, step %d: hypothesis %s, min chi %.3f, formula err %.1e, L1 ratio %.4f, L2 ratio %.4f, sup ratio %.3f\' % r)\ncheck(\'(G) the tree gauge fixing puts every tree link at I\', good_tree)\ncheck(\'(G) torus fields: coarse angles are the means of the 2x2 fluxes, cut-off inactive\', good_formula)\ncheck(\'(G) L1 ratio <= 1/4, L2 ratio <= 1, sup ratio <= 4 at every step\',\n all(r[5] <= 0.25 + 1e-12 and r[6] <= 1 + 1e-12 and r[7] <= 4 + 1e-12 for r in rows if r[0] != \'Q\' and r[2]))\ncheck(\'(G) Q_2(V#^2) <= 1.001 Q when eta0 * A <= eta_G^2\',\n all(r[3] <= 1.001 for r in rows if r[0] == \'Q\' and r[2]) and any(r[2] for r in rows if r[0] == \'Q\'))\n# (H)\ndef nrm(Z): return math.sqrt(hs2(Z))\ndef logs(U, Sz):\n return {(x, mu, nu): slog(plaq(U, x, mu, nu, Sz)) for x in itertools.product(range(Sz), repeat=d)\n for mu in range(d) for nu in range(mu + 1, d)}\ndef stats(L):\n v = [nrm(Z) for Z in L.values()]\n return sum(t * t for t in v), sum(v), max(v)\ndef pathp(U, x, mu, Sz): return U[(x, mu)] @ U[(shz(x, mu, Sz), mu)]\ndef nonab_step(cur, cs):\n Ug = gfix(cur, cs); nxt, cmin = step(cur, cs); ns = cs // 2\n Ln = logs(nxt, ns); worst, rmax = 0.0, 0.0\n for (yc, mu, nu), Th in Ln.items():\n y = 2 * np.array(yc)\n corner = [(y, mu), (y + 2 * E[mu], nu), (y + 2 * E[nu], mu), (y, nu)]\n K, Dmax = [], [0.0] * 4\n for o in blk:\n Pl = [pathp(Ug, tuple((c + o) % cs), m, cs) for c, m in corner]\n K.append(slog(Pl[0] @ Pl[1] @ inv(Pl[2]) @ inv(Pl[3])))\n for i, (c, m) in enumerate(corner):\n P0 = pathp(Ug, tuple(c % cs), m, cs)\n Dmax[i] = max(Dmax[i], nrm(slog(inv(P0) @ Pl[i])))\n Fbar = sum(K) / 16; r = sum(Dmax) + nrm(K[0])\n rmax = max(rmax, r); worst = max(worst, nrm(Th - Fbar) / (3.2 * r * r))\n return nxt, ns, cmin, worst, rmax\ngood_lem, good_steps, rows = True, True, []\nfor kind, eps in [(\'random\', 4e-5), (\'random\', 7e-5), (\'smooth\', 1e-4)]:\n U = {}\n g = {x: haar() for x in itertools.product(range(Sz), repeat=d)}\n for x in itertools.product(range(Sz), repeat=d):\n for mu in range(d):\n a = eps * rng.normal(size=3) if kind == \'random\' else \\\n eps * np.array([sum(math.sin(2 * math.pi * x[n] / Sz + cph[mu, n] + k) for n in range(d) if n != mu)\n for k in range(3)])\n U[(x, mu)] = g[x] @ su2(a) @ inv(g[shz(x, mu, Sz)])\n cur, cs = U, Sz\n for j in range(2):\n E0, A0, e0 = stats(logs(cur, cs))\n nxt, ns, cmin, worst, rmax = nonab_step(cur, cs)\n E1, A1, e1 = stats(logs(nxt, ns))\n ok_h = e0 <= rho / 1000\n good_lem &= (not ok_h) or (cmin == 1.0 and worst <= 1 and rmax <= 28.26 * e0)\n good_steps &= (not ok_h) or (math.sqrt(E1) <= (1 + 6030 * e0) * math.sqrt(E0) and\n A1 <= A0 / 4 * (1 + 9147 * e0) and e1 <= 4 * e0 * (1 + 647 * e0))\n rows.append((kind, eps, j, e0, ok_h, cmin, worst, math.sqrt(E1 / E0), 4 * A1 / A0, e1 / e0))\n cur, cs = nxt, ns\nfor r in rows:\n print(\' %s eps = %g, step %d: eta = %.2e (<= rho/1000: %s), min chi %.0f, max err/(3.2 r^2) = %.3f, \'\n \'sqrt(E1/E0) = %.4f, 4 A1/A0 = %.4f, eta1/eta0 = %.3f\' % r)\ncheck(\'(H) nonabelian small fields: cut-off inactive and |log V#_P - Fbar_P| <= 3.2 r_P^2, r_P <= 28.26 eta\', good_lem)\ncheck(\'(H) sqrt E grows by at most 1 + 6030 eta, A by (1/4)(1 + 9147 eta), eta by 4(1 + 647 eta)\', good_steps)\ncheck(\'(H) the nonabelian error term is present (max err/(3.2 r^2) > 0)\', max(r[6] for r in rows) > 1e-4)\n# (I)\ndef quad(f, a, b, n=20000):\n t = np.linspace(a, b, n + 1); w = np.full(n + 1, 2.0); w[0] = w[-1] = 1; w[1:-1:2] = 4\n return float(np.sum(w * f(t)) * (b - a) / (3 * n))\nLt = 8\ncubes = list(itertools.product(range(Lt), repeat=d))\ndef cube_plaqs(z):\n out = set()\n for w in itertools.product(range(2), repeat=d):\n for mu in range(d):\n for nu in range(mu + 1, d):\n if w[mu] == 0 and w[nu] == 0:\n out.add((tuple((np.array(z) + w) % Lt), mu, nu))\n return out\ncp = {z: cube_plaqs(z) for z in cubes}\ninc = {}\nfor z, P in cp.items():\n for p in P: inc[p] = inc.get(p, 0) + 1\ncheck(\'(I) a unit cube has 24 plaquettes and a plaquette lies in exactly 4 unit cubes\',\n all(len(P) == 24 for P in cp.values()) and set(inc.values()) == {4} and len(inc) == 6 * Lt ** 4)\nnb = len([w for w in itertools.product((-1, 0, 1), repeat=d) if any(w)])\ncheck(\'(I) a unit cube has 80 neighbours at l-infinity distance one\', nb == 80 and 80 ** 2 <= 6400)\ndef Zset(y, mu):\n return {tuple((2 * np.array(y) + t * E[mu] + np.array(w)) % Lt) for t in range(3)\n for w in itertools.product(range(2), repeat=d) if w[mu] == 0}\nZs = {(y, mu): Zset(y, mu) for y in itertools.product(range(Lt // 2), repeat=d) for mu in range(d)}\ncnt = {}\nfor k, Z in Zs.items():\n for z in Z: cnt[z] = cnt.get(z, 0) + 1\ncheck(\'(I) |Z_{y,mu}| = 24 and a cube lies in Z_{y,mu} for at most 8 coarse links\',\n all(len(Z) == 24 for Z in Zs.values()) and max(cnt.values()) <= 8)\nC0 = 0.5 + 2 / 3 * math.log(24 * math.pi ** 3)\nb0 = 11 * 2 / (48 * math.pi ** 2)\nprint(\' C_0 = %.4f, 4*8*4*24*144 = %d, 8 b_0 = %.4f\' % (C0, 4 * 8 * 4 * 24 * 144, 8 * b0))\ncheck(\'(I) 4*8*4*24*144 <= 4.5e5 and the one-loop slope 8 b_0 = 11/(3 pi^2) is below 4/3\',\n 4 * 8 * 4 * 24 * 144 <= 4.5e5 and abs(8 * b0 - 11 / (3 * math.pi ** 2)) < 1e-12 and 8 * b0 < 4 / 3)\ngood = True\nfor beta in [1, 3, 10, 100, 1e4]:\n r = 1 / (4 * math.sqrt(beta))\n pr = 2 / math.pi * quad(lambda t: np.sin(t) ** 2, 0, r)\n good &= pr >= 1 / (24 * math.pi ** 3 * beta ** 1.5)\ncheck(\'(I) a Haar link has angle <= (4 sqrt beta)^-1 with probability >= 1/(24 pi^3 beta^{3/2})\', good)\nvstar = 2 / math.pi * quad(lambda t: np.sin(t) ** 2, math.acos(0.75), math.pi / 3)\ngood = True; rows = []\nfor beta in [0.5, 1, 2, 5, 10]:\n for rho_ in [1.0, 0.5, 1 / 12]:\n t0 = math.acos(1 - rho_ ** 2 / 4)\n for kap in np.linspace(0, 6 * beta, 7):\n m = kap # stabilise the exponentials\n num = quad(lambda t: np.exp(kap * np.cos(t) - m) * np.sin(t) ** 2, t0, math.pi)\n den = quad(lambda t: np.exp(kap * np.cos(t) - m) * np.sin(t) ** 2, 0, math.pi)\n good &= num / den >= vstar * math.exp(-3 * beta) * (1 - 1e-9)\n rows.append((beta, vstar * math.exp(-3 * beta)))\nprint(\' v_* = %.5f; p = %s\' % (vstar, \', \'.join(\'%.3e at beta %g\' % (q, b) for b, q in rows)))\ncheck(\'(I) the angle exceeds arccos(1 - rho^2/4) with probability >= v_* e^{-3 beta} for kappa <= 6 beta\', good)\n# cap about I under the density e^{kappa h.u}: decreasing in the angle phi of h, increasing in kappa\ndef capprob(phi_, kap, th0, n=241):\n th = np.linspace(0, math.pi, n); al = np.linspace(0, math.pi, n)\n T, A = np.meshgrid(th, al, indexing=\'ij\')\n f = np.exp(kap * (math.cos(phi_) * np.cos(T) + math.sin(phi_) * np.sin(T) * np.cos(A) - 1)) * np.sin(T) ** 2 * np.sin(A)\n W = np.outer(np.where(th <= th0, 1.0, 0.0), np.ones(n))\n return float(np.trapezoid(np.trapezoid(f * W, al, axis=1), th) / np.trapezoid(np.trapezoid(f, al, axis=1), th))\ngood = True\nfor kap in [1.0, 4.0, 12.0]:\n vals = [capprob(ph, kap, 0.6) for ph in np.linspace(0, math.pi, 9)]\n good &= all(vals[i] >= vals[i + 1] - 1e-6 for i in range(len(vals) - 1))\nkv = [capprob(0.0, k, 0.6) for k in [0.0, 1.0, 4.0, 12.0]]\ngood &= all(kv[i] <= kv[i + 1] + 1e-6 for i in range(3))\ncheck(\'(I) the probability of a cap about I is largest at h = I and increases with kappa\', good)\n# frustrated exterior on a lattice of side 4\nS4 = 4; x0 = (1, 1, 1, 1)\nsh4 = lambda x, mu, k=1: tuple((np.array(x) + k * E[mu]) % S4)\nUf = {(x, mu): I2.copy() for x in itertools.product(range(S4), repeat=d) for mu in range(d)}\nfor nu, sgn in [(2, 1), (3, 1), (1, -1), (2, -1), (3, -1)]:\n Uf[(sh4(x0, nu, sgn), 0)] = -I2\ndef pl4(U, x, mu, nu):\n return U[(x, mu)] @ U[(sh4(x, mu), nu)] @ inv(U[(sh4(x, nu), mu)]) @ inv(U[(x, nu)])\ngood = True\nfor rep in range(5):\n Ue = haar(); Uf[(x0, 0)] = Ue\n tot = 0.0\n for nu in range(1, d):\n tot += pl4(Uf, x0, 0, nu).trace().real / 2 + pl4(Uf, sh4(x0, nu, -1), 0, nu).trace().real / 2\n good &= abs(tot - (-2 * Ue.trace().real)) < 1e-10 and np.allclose(pl4(Uf, x0, 0, 1), Ue)\ncheck(\'(I) frustrated exterior: the six plaquettes of e add to -2 Tr U_e and p_0 has holonomy U_e\', good)\nfr = []\nfor beta in [0.25, 0.5, 1, 2, 10]:\n t0 = math.acos(1 - 2.5 ** 2 / 4)\n num = quad(lambda t: np.exp(-4 * beta * (np.cos(t) + 1)) * np.sin(t) ** 2, t0, math.pi)\n den = quad(lambda t: np.exp(-4 * beta * (np.cos(t) + 1)) * np.sin(t) ** 2, 0, math.pi)\n fr.append(num / den)\nprint(\' frustrated exterior, rho = 2.5: P(p_0 bad) = %s at beta = 0.25, 0.5, 1, 2, 10\' % \', \'.join(\'%.6f\' % v for v in fr))\ncheck(\'(I) under the frustrated exterior p_0 is bad with probability increasing to 1\',\n all(fr[i] <= fr[i + 1] + 1e-12 for i in range(4)) and fr[-1] > 0.999)\n# chi = 1 off the bad cubes\nrho_b = 1 / 12; good, nact, nfree, nnear = True, 0, 0, 0\nfor rep in range(4):\n g = {x: haar() for x in itertools.product(range(Sz), repeat=d)}\n centres = [tuple(rng.integers(0, Sz, size=d)) for _ in range(2)]\n U = {}\n for x in itertools.product(range(Sz), repeat=d):\n for mu in range(d):\n big = any(max(min((x[n] - c[n]) % Sz, (c[n] - x[n]) % Sz) for n in range(d)) == 0 for c in centres)\n a = rng.normal(size=3) * (0.8 if big else 1.5e-3)\n U[(x, mu)] = g[x] @ su2(a) @ inv(g[shz(x, mu, Sz)])\n bad = set()\n for x in itertools.product(range(Sz), repeat=d):\n for mu in range(d):\n for nu in range(mu + 1, d):\n if nrm(plaq(U, x, mu, nu, Sz) - I2) > rho_b:\n for w in itertools.product(range(2), repeat=d):\n if w[mu] == 0 and w[nu] == 0:\n bad.add(tuple((np.array(x) - np.array(w)) % Sz))\n Ug = gfix(U, Sz)\n for y in itertools.product(range(0, Sz, 2), repeat=d):\n for mu in range(d):\n Z = {tuple((np.array(y) + t * E[mu] + np.array(w)) % Sz) for t in range(3)\n for w in itertools.product(range(2), repeat=d) if w[mu] == 0}\n chi = sharpz(Ug, y, mu, Sz)[1]\n if Z & bad: nnear += 1; nact += chi < 1\n else: nfree += 1; good &= chi == 1.0\nprint(\' coarse links with a bad cube in Z: %d (chi < 1 at %d); without: %d\' % (nnear, nact, nfree))\ncheck(\'(I) chi = 1 at every coarse link whose 24 cubes are good (rho = 1/12)\', good and nfree > 0 and nnear > 0)\n# (J)\ndef plaq_pts(x, mu, nu, Sz):\n return [tuple((np.array(x) + a * E[mu] + b * E[nu]) % Sz) for a in (0, 1) for b in (0, 1)]\ndef linf(p, q, Sz):\n return max(min((p[n] - q[n]) % Sz, (q[n] - p[n]) % Sz) for n in range(d))\ndef propagate(Bset, cs):\n out = set()\n for y in itertools.product(range(cs // 2), repeat=d):\n box = {tuple((2 * np.array(y) + np.array(o)) % cs) for o in itertools.product(range(4), repeat=d)}\n for mu in range(d):\n for nu in range(mu + 1, d):\n if any(x in box for (x, m, n) in Bset): out.add((y, mu, nu))\n return out\ngood_def, good_dist, good_E, rows = True, True, True, []\nnonempty = True\nfor rep in range(3):\n g = {x: haar() for x in itertools.product(range(Sz), repeat=d)}\n c0 = tuple(rng.integers(0, Sz, size=d))\n U = {}\n for x in itertools.product(range(Sz), repeat=d):\n for mu in range(d):\n big = x == c0 and mu == 0\n a = rng.normal(size=3) * (0.9 if big else 1e-5)\n U[(x, mu)] = g[x] @ su2(a) @ inv(g[shz(x, mu, Sz)])\n eta0 = 4e-4\n L0 = logs(U, Sz)\n B = {k for k, Z in L0.items() if nrm(plaq(U, k[0], k[1], k[2], Sz) - I2) > 1 or nrm(Z) > eta0}\n B0pts = [pt for (x, m, n) in B for pt in plaq_pts(x, m, n, Sz)]\n Eo0 = sum(nrm(Z) ** 2 for k, Z in L0.items() if k not in B)\n cur, cs, eta, sgm, Bj = U, Sz, eta0, 0.0, B\n for j in range(1):\n nxt, cmin = step(cur, cs); ns = cs // 2\n Bn = propagate(Bj, cs); sgm += eta; eta = 4 * (1 + 647 * eta) * eta\n Ln = {}\n for (y, mu, nu) in itertools.product(itertools.product(range(ns), repeat=d), range(d), range(d)):\n if mu < nu and (y, mu, nu) not in Bn:\n P = plaq(nxt, y, mu, nu, ns)\n good_def &= nrm(P - I2) <= 1 and nrm(slog(P)) <= eta\n Ln[(y, mu, nu)] = slog(P)\n scale = 2 ** (j + 1)\n for (y, mu, nu) in Bn:\n for pt in plaq_pts(y, mu, nu, ns):\n fine = tuple(scale * q for q in pt)\n good_dist &= min(linf(fine, b, Sz) for b in B0pts) <= 3 * (scale - 1)\n Eo = sum(nrm(Z) ** 2 for Z in Ln.values())\n good_E &= Eo <= math.exp(12060 * sgm) * Eo0\n nonempty &= len(Ln) > 0 and len(B) > 0\n rows.append((rep, j + 1, len(B), len(Bn), max(nrm(Z) for Z in Ln.values()) / eta if Ln else 0.0, Eo / Eo0))\n cur, cs, Bj = nxt, ns, Bn\nfor r in rows:\n print(\' field %d, step %d: |B_0| = %d, |B_j| = %d, max |Theta| off B_j / eta_j = %.3f, E_j off B_j / E_0 off B_0 = %.4f\' % r)\ncheck(\'(J) off the propagated defects |Theta^(j)| <= eta_j and delta <= 1\', good_def and nonempty)\ncheck(\'(J) the defects of the j-th iterate lie within 3(2^j - 1) fine spacings of B_0\', good_dist)\ncheck(\'(J) the energy off the defects obeys E_j <= e^{12060 sigma} E_0\', good_E)\n# (K) uniform upper bound for the effective forms: Whitney extension with nodes at the block centres\ndef whitney_int(u, L, dim):\n # returns Pi u times S = 16 L^4 (dim = 4) as an integer array; u integer, periodic coarse lattice\n n = u.shape[0]; F = n * L\n X = np.indices((F,) * dim)\n S = 2 * (2 * L) ** (dim - 1) * L\n phi = np.zeros((F,) * dim + (dim,), dtype=np.int64)\n for mu in range(dim):\n acc = np.zeros((F,) * dim, dtype=np.int64)\n for z in itertools.product(range(n), repeat=dim):\n w = np.ones((F,) * dim, dtype=np.int64)\n for nu in range(dim):\n c2 = 2 * L * z[nu] + L - 1 # twice the centre\n x2 = 2 * X[nu]\n tot = np.zeros((F,) * dim, dtype=np.int64)\n for sh in (-2 * F, 0, 2 * F):\n if nu == mu: # twice the overlap of [x, x+1) with [c, c+L)\n tot += np.maximum(0, np.minimum(x2 + 2, c2 + sh + 2 * L) - np.maximum(x2, c2 + sh))\n else: # 2L times the hat function\n tot += np.maximum(0, 2 * L - np.abs(x2 - c2 - sh))\n w = w * tot\n acc += u[z + (mu,)] * w\n phi[..., mu] = acc\n return phi, S # phi = S (Pi u): overlap doubled, hats times 2L, and the 1/L of omega\ndef curv_int(f, dim):\n out = []\n for mu in range(dim):\n for nu in range(mu + 1, dim):\n out.append(f[..., mu] + np.roll(f[..., nu], -1, mu) - np.roll(f[..., mu], -1, nu) - f[..., nu])\n return np.array(out)\nrngK = np.random.default_rng(7)\ngood_T, good_Q, good_g = True, True, True\nfor (dim, n, L) in ((4, 3, 2), (4, 3, 4), (2, 4, 8), (3, 3, 4)):\n for trial in range(2):\n u = rngK.integers(-3, 4, size=(n,) * dim + (dim,))\n phi, S = whitney_int(u, L, dim)\n F = n * L\n # L^4 S times the k-fold averages, from straight paths of length L\n lhs = np.zeros((n,) * dim + (dim,), dtype=np.int64)\n for mu in range(dim):\n ps = sum(np.roll(phi[..., mu], -t, mu) for t in range(L))\n for z in itertools.product(range(n), repeat=dim):\n sl = tuple(slice(L * zi, L * zi + L) for zi in z)\n lhs[z + (mu,)] = ps[sl].sum()\n Tu = u.astype(np.int64) * 1\n for nu in range(dim):\n Tu = 6 * Tu + np.roll(Tu, 1, nu) + np.roll(Tu, -1, nu) # 8 tau\n good_T &= np.array_equal(lhs * 8 ** dim, Tu * S * L ** dim)\n good_Q &= int((curv_int(phi, dim) ** 2).sum()) <= int((curv_int(u, dim) ** 2).sum()) * S * S\n b = rngK.integers(-3, 4, size=(n,) * dim)\n db = np.stack([np.roll(b, -1, m) - b for m in range(dim)], -1)\n good_g &= not np.any(curv_int(whitney_int(db, L, dim)[0], dim))\ncheck(\'(K) the k-fold averages of the Whitney extension are T u, T = tau^(x d), tau = (1/8, 3/4, 1/8) (exact)\', good_T)\ncheck(\'(K) Q(Pi u) <= Q_k(u) and Pi(db) has zero curvature (exact)\', good_Q and good_g)\nth = np.linspace(0, np.pi, 2001)\ncheck(\'(K) the symbol 3/4 + cos(theta)/4 of tau is at least 1/2, and 1/L with coarse sites as nodes\',\n np.min(0.75 + 0.25 * np.cos(th)) >= 0.5 - 1e-15 and all(abs((L + 1) / (2 * L) - (L - 1) / (2 * L) - 1 / L) < 1e-15 for L in (2, 4, 8, 16)))\nprint(\'%d checks passed, %d failed\' % (sum(ok), len(ok) - sum(ok)))\n', 'private_submersion.py': '"""Checks of the lower bound for the derivative of the cut-off average along\nits eight private links (lemma privatesubmersion).\n\nFor one coarse link the private links are the straight link l_0 and the seven\nlinks l_a, a != 0, that leave B(y) in the direction mu. With inner links u_a,\nw_a the paths are P = l_0, P_x = u_a l_a and P_x\' = l_a w_a. The script\n(A) checks the constants: the eigenvalue angle bound 2 arcsin(1/(2 sqrt 2)),\n Lambda = alpha/sin(alpha) < 1.0927, 1 - 7 Lambda/8 > 0.0439 and\n sigma_0 = (1 - 7 Lambda/8)/sqrt 2 > 0.031;\n(B) on random fields of SU(2) and SU(3), Haar inner links and every value of\n the cut-off, applies the test variation of the proof (straight link and the\n link of the maximising path) and checks |T zeta| >= (1 - 7 Lambda/8)|zeta|,\n with derivatives by central differences;\n(C) checks that the least singular value of the private derivative is at least\n sigma_0 on the same fields.\nDouble precision; the proof in the paper is by hand.\nUsage: python3 private_submersion.py\n"""\nimport itertools\nimport numpy as np\nfrom scipy.linalg import expm, logm\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append(bool(ok))\n print(("PASS " if ok else "FAIL ") + name)\n\n\ndef basis(N):\n """Orthonormal basis of su(N) for = Re tr(X^* Y)."""\n B = []\n for j in range(N):\n for k in range(j + 1, N):\n E = np.zeros((N, N), complex); E[j, k] = 1; E[k, j] = -1\n B.append(E / np.sqrt(2))\n E = np.zeros((N, N), complex); E[j, k] = 1j; E[k, j] = 1j\n B.append(E / np.sqrt(2))\n for d in range(1, N):\n D = np.zeros((N, N), complex)\n D[:d, :d] = np.eye(d) * 1j; D[d, d] = -1j * d\n B.append(D / np.linalg.norm(D))\n return B\n\n\ndef coords(B, X):\n return np.array([np.real(np.trace(b.conj().T @ X)) for b in B])\n\n\ndef alg(B, c):\n return sum(ci * b for ci, b in zip(c, B))\n\n\ndef haar(N, rng):\n Z = (rng.normal(size=(N, N)) + 1j * rng.normal(size=(N, N))) / np.sqrt(2)\n Q, R = np.linalg.qr(Z)\n Q = Q @ np.diag(np.diag(R) / np.abs(np.diag(R)))\n return Q / np.linalg.det(Q) ** (1 / N)\n\n\ndef lg(g):\n X = logm(g)\n return (X - X.conj().T) / 2\n\n\ndef phi(t):\n return min(1.0, max(0.0, 2 - 2 * t))\n\n\ndef cutoff(l, u, w, rho):\n P = l[0]\n Ps = []\n for a in range(1, 8):\n Ps += [u[a] @ l[a], l[a] @ w[a]]\n d = [np.linalg.norm(Px - P) for Px in Ps]\n m = max(d)\n chi = phi(m / rho)\n if chi == 0:\n return P, chi, m, None\n M = sum(lg(P.conj().T @ Px) for Px in Ps) / 16\n return P @ expm(chi * M), chi, m, int(np.argmax(d))\n\n\ndef right_deriv(B, f, h=1e-6):\n """Right-trivialised derivative of t -> f(t) at 0 in the basis B."""\n Vp, Vm, V0 = f(h), f(-h), f(0.0)\n return coords(B, lg(Vp @ V0.conj().T) - lg(Vm @ V0.conj().T)) / (2 * h)\n\n\nALPHA = 2 * np.arcsin(1 / (2 * np.sqrt(2)))\nLAM = ALPHA / np.sin(ALPHA)\nMARGIN = 1 - 7 * LAM / 8\nSIGMA0 = MARGIN / np.sqrt(2)\ncheck(f"alpha = 2 arcsin(1/(2 sqrt 2)) = {ALPHA:.6f} < 1.4455/2", ALPHA < 1.4455 / 2)\ncheck(f"Lambda = {LAM:.6f} < 1.0927", LAM < 1.0927)\ncheck(f"1 - 7 Lambda/8 = {MARGIN:.6f} > 0.0439", MARGIN > 0.0439)\ncheck(f"sigma_0 = {SIGMA0:.6f} > 0.031", SIGMA0 > 0.031)\n# two eigenvalue angles a, b with 4 sin^2(a/2) + 4 sin^2(b/2) <= 1 have a + b <= 2 alpha\nts = np.linspace(0, np.pi, 200001)\ns = 4 * np.sin(ts / 2) ** 2\nbmax = np.where(s <= 1, 2 * np.arcsin(np.sqrt(np.clip(1 - s, 0, 1)) / 2), -1)\ncheck("max a + b under 4sin^2(a/2)+4sin^2(b/2) <= 1 equals 2 alpha",\n abs(np.max(np.where(bmax >= 0, ts + bmax, 0)) - 2 * ALPHA) < 1e-4)\n\n\ndef sample(N, rng, rho):\n B = basis(N)\n while True:\n l0 = haar(N, rng)\n sc = rng.uniform(0.05, 0.75)\n l, u, w = [l0], [None], [None]\n for a in range(1, 8):\n ua = haar(N, rng)\n v1 = expm(alg(B, rng.normal(size=len(B)) * sc / np.sqrt(len(B))))\n v2 = expm(alg(B, rng.normal(size=len(B)) * sc / np.sqrt(len(B))))\n la = ua.conj().T @ l0 @ v1\n l.append(la); u.append(ua); w.append(la.conj().T @ l0 @ v2)\n V, chi, m, xs = cutoff(l, u, w, rho)\n if chi > 0:\n return B, l, u, w, chi, m, xs\n\n\nworst_T, worst_s, counts = 9.0, 9.0, {"switch": 0, "average": 0}\nfor N, rho, trials in ((2, 1.0, 150), (3, 1.0, 60)):\n rng = np.random.default_rng(N)\n gT, gs = 9.0, 9.0\n for t in range(trials):\n B, l, u, w, chi, m, xs = sample(N, rng, rho)\n counts["switch" if chi < 1 else "average"] += 1\n a_star = xs // 2 + 1\n first = xs % 2 == 0 # maximiser is u_a l_a\n P = l[0]\n zeta = rng.normal(size=len(B)); zeta /= np.linalg.norm(zeta)\n Z = alg(B, zeta)\n eta = P @ Z @ P.conj().T # P-frame vector zeta, moved to the identity\n\n def f(tt):\n ll = list(l)\n ll[0] = expm(tt * eta) @ l[0]\n if chi < 1:\n if first: # eta\'_{x} = zeta at x = (a*, 1)\n xi = u[a_star].conj().T @ eta @ u[a_star]\n else: # eta\'_{x\'} = zeta\n xi = eta\n ll[a_star] = expm(tt * xi) @ l[a_star]\n return cutoff(ll, u, w, rho)[0]\n\n out = right_deriv(B, f)\n gT = min(gT, np.linalg.norm(out))\n cols = []\n for a in range(8):\n for k in range(len(B)):\n def g(tt, a=a, k=k):\n ll = list(l); ll[a] = expm(tt * B[k]) @ l[a]\n return cutoff(ll, u, w, rho)[0]\n cols.append(right_deriv(B, g))\n sv = np.linalg.svd(np.array(cols).T, compute_uv=False)[-1]\n gs = min(gs, sv)\n worst_T, worst_s = min(worst_T, gT), min(worst_s, gs)\n print(f"SU({N}): fields {trials}, least |T zeta| {gT:.4f}, least sigma {gs:.4f}")\ncheck(f"test variation |T zeta| >= 1 - 7 Lambda/8 on every sampled field "\n f"({counts[\'switch\']} in the switch region, {counts[\'average\']} averaging)",\n worst_T >= MARGIN)\ncheck(f"least singular value of the private derivative >= sigma_0 (least {worst_s:.4f})",\n worst_s >= SIGMA0)\nprint(f"{sum(checks)} of {len(checks)} checks passed")\n', 'ricci.py': '"""Ricci constants of the compact simple groups in a faithful representation.\n\nFor a compact simple group G with a faithful unitary representation rho of\ndimension n, the metric = -Tr(rho(X) rho(Y)) is bi-invariant, and the\nRicci curvature is Ric = c/4, where B = c * (trace form) and B is the Killing\nform. On a Cartan element H, B(H,H) = sum over roots a of a(H)^2 and the trace\nform is sum over weights m of rho (with multiplicity) of m(H)^2. Simplicity\nmakes the ratio independent of H; this is checked on several H.\n\nThe script works in exact rational arithmetic and prints, for every group,\nRic, the dual Coxeter number, the Dynkin index, and the ranges\nn|beta| < 2 Ric/29 and beta_W = n^2 beta < 2 n Ric/29 of the forest-gauge\ncurvature theorem. Run: python3 ricci.py\n"""\nfrom fractions import Fraction as Fr\nfrom itertools import combinations, product\nimport random\n\ndef vec(*xs):\n return tuple(Fr(x) for x in xs)\n\ndef dot(a, b):\n return sum(x * y for x, y in zip(a, b))\n\ndef unit(n, i, s=1):\n return tuple(Fr(s) if k == i else Fr(0) for k in range(n))\n\ndef add(a, b, s=1):\n return tuple(x + s * y for x, y in zip(a, b))\n\ndef roots_A(n): # A_n in R^{n+1}\n m = n + 1\n return [add(unit(m, i), unit(m, j), -1) for i in range(m) for j in range(m) if i != j]\n\ndef weights_A(n):\n m = n + 1\n avg = tuple(Fr(1, m) for _ in range(m))\n return [add(unit(m, i), avg, -1) for i in range(m)]\n\ndef pm_pairs(n):\n out = []\n for i, j in combinations(range(n), 2):\n for s, t in product((1, -1), repeat=2):\n out.append(add(unit(n, i, s), unit(n, j, t)))\n return out\n\ndef roots_B(n):\n return pm_pairs(n) + [unit(n, i, s) for i in range(n) for s in (1, -1)]\n\ndef weights_B(n): # vector of SO(2n+1)\n return [unit(n, i, s) for i in range(n) for s in (1, -1)] + [tuple(Fr(0) for _ in range(n))]\n\ndef roots_C(n):\n return pm_pairs(n) + [unit(n, i, 2 * s) for i in range(n) for s in (1, -1)]\n\ndef weights_C(n): # fundamental of Sp(n), dimension 2n\n return [unit(n, i, s) for i in range(n) for s in (1, -1)]\n\ndef roots_D(n):\n return pm_pairs(n)\n\ndef weights_D(n): # vector of SO(2n)\n return [unit(n, i, s) for i in range(n) for s in (1, -1)]\n\ndef roots_G2():\n e = [unit(3, i) for i in range(3)]\n long_ = [add(e[i], e[j], -1) for i in range(3) for j in range(3) if i != j]\n short = []\n for i in range(3):\n j, k = [x for x in range(3) if x != i]\n v = tuple((2 * e[i][t] - e[j][t] - e[k][t]) / 3 for t in range(3))\n short += [v, tuple(-x for x in v)]\n return long_ + short, short\n\ndef weights_G2():\n _, short = roots_G2()\n return short + [tuple(Fr(0) for _ in range(3))]\n\ndef roots_F4():\n short = [unit(4, i, s) for i in range(4) for s in (1, -1)]\n short += [tuple(Fr(s, 2) for s in signs) for signs in product((1, -1), repeat=4)]\n return pm_pairs(4) + short, short\n\ndef weights_F4():\n _, short = roots_F4()\n return short + [tuple(Fr(0) for _ in range(4))] * 2\n\ndef roots_E8():\n r = pm_pairs(8)\n for signs in product((1, -1), repeat=8):\n if signs.count(-1) % 2 == 0:\n r.append(tuple(Fr(s, 2) for s in signs))\n return r\n\ndef project(v, basis):\n """Orthogonal projection of v onto the complement of span(basis) (basis orthogonalised)."""\n ob = []\n for b in basis:\n w = b\n for o in ob:\n w = add(w, o, -dot(w, o) / dot(o, o))\n ob.append(w)\n for o in ob:\n v = add(v, o, -dot(v, o) / dot(o, o))\n return v\n\ndef E7_data():\n R = roots_E8()\n r = R[0]\n roots = [a for a in R if dot(a, r) == 0]\n wts = [project(a, [r]) for a in R if dot(a, r) == 1]\n return roots, wts, [r]\n\ndef E6_data():\n R = roots_E8()\n r1 = R[0]\n r2 = next(a for a in R if dot(a, r1) == -1) # r1, r2 simple roots of an A2\n roots = [a for a in R if dot(a, r1) == 0 and dot(a, r2) == 0]\n wts = [project(a, [r1, r2]) for a in R if (dot(a, r1), dot(a, r2)) == (1, 0)]\n return roots, wts, [r1, r2]\n\ndef ratio(roots, wts, dim, perp=()):\n vals = set()\n rng = random.Random(7)\n for _ in range(4):\n H = tuple(Fr(rng.randint(-9, 9), rng.randint(1, 5)) for _ in range(dim))\n if perp:\n H = project(H, list(perp))\n if all(x == 0 for x in H):\n continue\n num = sum(dot(a, H) ** 2 for a in roots)\n den = sum(dot(m, H) ** 2 for m in wts)\n vals.add(num / den)\n assert len(vals) == 1, vals\n return vals.pop()\n\ndef sumzero(H):\n m = len(H)\n s = sum(H) / m\n return tuple(x - s for x in H)\n\ndef main():\n rows = []\n for n in range(1, 8):\n rows.append((f"SU({n+1})", n + 1, roots_A(n), weights_A(n), n + 1, "A"))\n for n in range(2, 7):\n rows.append((f"Sp({n})", 2 * n, roots_C(n), weights_C(n), n, ""))\n for n in range(1, 6):\n rows.append((f"SO({2*n+1})", 2 * n + 1, roots_B(n), weights_B(n), n, ""))\n for n in range(3, 7):\n rows.append((f"SO({2*n})", 2 * n, roots_D(n), weights_D(n), n, ""))\n g2r, _ = roots_G2()\n rows.append(("G2", 7, g2r, weights_G2(), 3, "A"))\n f4r, _ = roots_F4()\n rows.append(("F4", 26, f4r, weights_F4(), 4, ""))\n e6r, e6w, e6p = E6_data()\n e7r, e7w, e7p = E7_data()\n e8r = roots_E8()\n print(f"{\'group\':8} {\'n\':>4} {\'#roots\':>6} {\'#wts\':>5} {\'Ric\':>8} {\'h\':>4} {\'index\':>6} {\'n|beta| <\':>10} {\'beta_W <\':>10}")\n out = []\n for name, nrep, roots, wts, dim, kind in rows + [("E6", 27, e6r, e6w, 8, "E6"), ("E7", 56, e7r, e7w, 8, "E7"),\n ("E8", 248, e8r, e8r + [tuple(Fr(0) for _ in range(8))] * 8, 8, "")]:\n assert len(wts) == nrep, (name, len(wts))\n perp = ()\n if kind == "E6":\n perp = e6p\n elif kind == "E7":\n perp = e7p\n if kind in ("A",):\n # Cartan of A_n and of G2 lies in the sum-zero hyperplane\n vals = set()\n rng = random.Random(3)\n for _ in range(4):\n H = sumzero(tuple(Fr(rng.randint(-9, 9), rng.randint(1, 5)) for _ in range(dim)))\n vals.add(sum(dot(a, H) ** 2 for a in roots) / sum(dot(m, H) ** 2 for m in wts))\n assert len(vals) == 1, (name, vals)\n c = vals.pop()\n else:\n c = ratio(roots, wts, dim, perp)\n ric = c / 4\n # dual Coxeter number h and Dynkin index l: l_adj = 2h and c = l_adj / l_rho\n # h from the highest root theta: 2h = (1/2) sum_a ^2\n long2 = max(dot(a, a) for a in roots)\n theta = max(roots, key=lambda a: (dot(a, a), a))\n thv = tuple(2 * x / dot(theta, theta) for x in theta)\n two_h = sum(dot(a, thv) ** 2 for a in roots) / 2\n index = sum(dot(m, thv) ** 2 for m in wts) / 2\n assert two_h / index == c, (name, two_h, index, c)\n h = two_h / 2\n out.append((name, nrep, ric, h, index))\n print(f"{name:8} {nrep:>4} {len(roots):>6} {len(wts):>5} {str(ric):>8} {str(h):>4} {str(index):>6} {str(2*ric/29):>10} {str(2*nrep*ric/29):>10}")\n # checks against the closed forms\n known = {"G2": (Fr(1), 4, 2), "F4": (Fr(3, 4), 9, 6), "E6": (Fr(1), 12, 6), "E7": (Fr(3, 4), 18, 12), "E8": (Fr(1, 4), 30, 60)}\n for name, nrep, ric, h, index in out:\n if name.startswith("SU("):\n N = nrep\n assert ric == Fr(N, 2) and h == N and index == 1\n elif name.startswith("Sp("):\n k = nrep // 2\n assert ric == Fr(k + 1, 2) and h == k + 1 and index == 1\n elif name.startswith("SO("):\n N = nrep\n assert ric == Fr(N - 2, 4), (name, ric)\n if N >= 5:\n assert h == N - 2 and index == 2, (name, h, index)\n else:\n assert (ric, h, index) == known[name], (name, ric, h, index)\n print("all closed forms confirmed")\n\nif __name__ == "__main__":\n main()\n', 'romanov_certificate.py': '"""Check of Romanov\'s site-plus-plaquette certificate for the forest-gauge Hessian, h_F <= 14.420001.\n\nThe certificate (cert4d_h14.42.json, data of github.com/romanov360/yang-mills-4d-forest-certificate, MIT licence,\nsee NOTICE_romanov.yaml) is read as data. Everything else is computed here:\n 1. the finite part in exact rational arithmetic: the sixteen vertex forms G_y are positive definite with\n G_y[o_mu, i_mu] = 0, the plaquette weights are nonnegative, the largest per-link total is 14420001/10^6;\n 2. on the torus of side two with random U(2) and U(3) fields: the Hessian of sum_p Re Tr Q_p equals the sum of\n the plaquette forms f_p(Y, W) of Q_p(t) = e^{tY1} e^{tY2} W e^{-tY3} e^{-tY4}, and the corner terms of the\n plaquettes add up to the vertex forms minus their diagonals;\n 3. every plaquette matrix M_p(phi) is positive definite for all phases: least eigenvalue at the centre of each\n cell of an adaptive grid, against a bound for |M_p(phi) - M_p(centre)| over the cell.\nUsage: python3 romanov_certificate.py cert4d_h14.42.json [first last] (part 3 for plaquettes first..last-1)\n"""\nimport json, itertools, time, numpy as np\nfrom fractions import Fraction as Fr\nfrom scipy.linalg import expm\nrng=np.random.default_rng(1)\nd=4; sites=sorted(itertools.product((0,1),repeat=4))\nPAT="0212331001332120"; mu_of={s:int(PAT[i]) for i,s in enumerate(sites)}\nsh=lambda x,a:tuple((x[i]+(i==a))%2 for i in range(4))\nedges=[(x,a) for x in sites for a in range(4)]; eidx={e:i for i,e in enumerate(edges)}\nfixed={eidx[(y,a)] for (y,a) in edges if mu_of[sh(y,a)]==a}\nPL=[]\nfor x in sites:\n for m in range(4):\n for n in range(m+1,4):\n p=(eidx[(x,m)],eidx[(sh(x,m),n)],eidx[(sh(x,n),m)],eidx[(x,n)])\n corners=((x,m,n),(sh(x,m),4+m,n),(sh(sh(x,m),n),4+n,4+m),(sh(x,n),m,4+n))\n PL.append((p,corners,[i for i in range(4) if p[i] not in fixed]))\nassert len(fixed)==16 and all(len(f)==3 for _,_,f in PL)\nimport sys\ncert=json.load(open(sys.argv[1]))\nG={tuple(json.loads(k)):[[Fr(v) for v in r] for r in g] for k,g in cert[\'G\'].items()}\nA=[{int(i):Fr(v) for i,v in a.items()} for a in cert[\'A\']]\n# ---- 1. finite part, exact ----\ndef pd(M):\n M=[r[:] for r in M]; n=len(M)\n for j in range(n):\n if M[j][j]<=0: return False\n for i in range(j+1,n):\n f=M[i][j]/M[j][j]\n for k in range(j,n): M[i][k]-=f*M[j][k]\n return True\nfor y in sites:\n g=G[y]; assert all(g[i][j]==g[j][i] for i in range(8) for j in range(8)); assert all(g[m][4+m]==0 for m in range(4)); assert pd(g)\nassert all(v>=0 for a in A for v in a.values()) and all(set(a)==set(f) for a,(_,_,f) in zip(A,PL))\ntot={e:Fr(0) for e in range(64) if e not in fixed}\nfor (x,m) in edges:\n e=eidx[(x,m)]\n if e not in fixed: tot[e]+=G[x][m][m]+G[sh(x,m)][4+m][4+m]\nfor (p,_,f),a in zip(PL,A):\n for i in f: tot[p[i]]+=a[i]\nh=max(tot.values()); print(\'finite part: 16 G_y PD, weights>=0, h =\',h,float(h)); assert h==Fr(cert[\'h\'])\n# ---- 2. the plaquette form, derived here: Q_p(t)=e^{tY1}e^{tY2} W e^{-tY3} e^{-tY4} ----\ndef f2(Y,W):\n # t^2 coefficient times 2 of the product of the four exponentials around W\n fac=[(Y[0],1),(Y[1],1),(None,0),(Y[2],-1),(Y[3],-1)]\n I=np.eye(len(W)); ser=[I,0*I,0*I]\n for Yk,s in fac:\n if Yk is None: ser=[S@W for S in ser]; continue\n T=[I,s*Yk,Yk@Yk/2]\n ser=[sum(ser[i]@T[k-i] for i in range(k+1)) for k in range(3)]\n return 2*np.trace(ser[2]).real\nip=lambda X,Y:-np.trace(X@Y).real\ndef randu(N):\n Z=rng.normal(size=(N,N))+1j*rng.normal(size=(N,N)); q,r=np.linalg.qr(Z); return q*(np.diag(r)/abs(np.diag(r)))\ndef randalg(N):\n Z=rng.normal(size=(N,N))+1j*rng.normal(size=(N,N)); return (Z-Z.conj().T)/2\ns_=[np.array([[0,1],[1,0]],complex),np.array([[0,-1j],[1j,0]]),np.array([[1,0],[0,-1]],complex)]\nBAS=[1j*np.eye(2)/np.sqrt(2)]+[1j*m/np.sqrt(2) for m in s_]\ndef qmat(form):\n vec=lambda v:[sum(v[4*i+a]*BAS[a] for a in range(4)) for i in range(4)]\n E=np.eye(16); dd=np.array([form(vec(E[i])) for i in range(16)]); M=np.diag(dd)\n for i in range(16):\n for j in range(i+1,16): M[i,j]=M[j,i]=(form(vec(E[i]+E[j]))-dd[i]-dd[j])/2\n return M\nD_=lambda a,b:np.diag([a,b]).astype(complex)\nFB=[qmat(lambda Y,W=W:f2(Y,W)) for W in (D_(1,0),D_(1j,0),D_(0,1),D_(0,1j))]\nc23=lambda W:qmat(lambda Y:ip(Y[1],W@Y[2]@W.conj().T))\nC0,Cpi,Ch=c23(D_(1,1)),c23(D_(1,-1)),c23(D_(1j,1))\nCB=[(C0+Cpi)/2,(C0-Cpi)/2,Ch-(C0+Cpi)/2]\n# check decompositions at random phases\nfor _ in range(5):\n a,b=rng.uniform(0,2*np.pi,2); W=D_(np.exp(1j*a),np.exp(1j*b))\n assert np.abs(qmat(lambda Y:f2(Y,W))-(np.cos(a)*FB[0]+np.sin(a)*FB[1]+np.cos(b)*FB[2]+np.sin(b)*FB[3])).max()<1e-12\n assert np.abs(c23(W)-(CB[0]+np.cos(a-b)*CB[1]+np.sin(a-b)*CB[2])).max()<1e-12\ndef cm(i,j):\n M=np.zeros((16,16)); M[4*i:4*i+4,4*j:4*j+4]=0.5*np.eye(4); return M+M.T\nC14,C12,C34=cm(0,3),cm(0,1),cm(2,3)\nnrm=lambda M:np.linalg.norm(M,2)\ndef run(j,m=64,maxdepth=12):\n p,c,f=PL[j]; k=[2*float(G[s][r][q]) for s,r,q in c]\n idx=[4*i+q for i in f for q in range(4)]; R=lambda M:M[np.ix_(idx,idx)]\n D=np.zeros((16,16))\n for i in f: D[4*i:4*i+4,4*i:4*i+4]=float(A[j][i])*np.eye(4)\n K0=R(D-k[0]*C14-k[1]*C12-k[3]*C34-k[2]*CB[0]); F=[R(x) for x in FB]; C1,C2=R(CB[1]),R(CB[2])\n nF=[nrm(x) for x in F]; nC=[nrm(C1),nrm(C2)]; kk=abs(k[2])\n cells=np.array([(a,b) for a in range(m) for b in range(m)],float); n=m; total=0; lmin=np.inf\n for depth in range(maxdepth+1):\n r=np.pi/n; lam_all=[]; bad_all=[]\n for c0 in range(0,len(cells),100000):\n cc=cells[c0:c0+100000]\n ph=(2*cc+1)*np.pi/n; p1,p2=ph[:,0],ph[:,1]; dl=p1-p2\n M=(K0[None]-np.cos(p1)[:,None,None]*F[0]-np.sin(p1)[:,None,None]*F[1]-np.cos(p2)[:,None,None]*F[2]-np.sin(p2)[:,None,None]*F[3]\n -k[2]*(np.cos(dl)[:,None,None]*C1+np.sin(dl)[:,None,None]*C2))\n lam=np.linalg.eigvalsh(M)[:,0]\n # |cos(c+t)-cos c|<=|t||sin c|+t^2/2 etc., |t|<=r for phi1, phi2 and |t|<=2r for phi1-phi2\n q=lambda c,rr:(rr*np.abs(np.sin(c))+rr*rr/2, rr*np.abs(np.cos(c))+rr*rr/2)\n a1,b1=q(p1,r); a2,b2=q(p2,r); a3,b3=q(dl,2*r)\n bound=a1*nF[0]+b1*nF[1]+a2*nF[2]+b2*nF[3]+kk*(a3*nC[0]+b3*nC[1])\n lam_all.append(lam); bad_all.append(lam<=bound+1e-9)\n lam=np.concatenate(lam_all); bad=np.concatenate(bad_all); lmin=min(lmin,lam.min()); total+=len(cells)\n if lam.min()<=0: return False,depth,total,lmin\n if not bad.any(): return True,depth,total,lmin\n cells=np.concatenate([2*cells[bad]+o for o in ((0,0),(0,1),(1,0),(1,1))]); n*=2\n return False,depth,total,lmin\n\nif __name__==\'__main__\':\n if len(sys.argv)<=2:\n # global identity test on the L=2 torus with random U(N) field: Hess(X,X) = sum_p f2(Y_p,W_p); corner sums\n for N in (2,3):\n Q=[randu(N) for _ in edges]; X=[randalg(N) for _ in edges]\n S=lambda t:sum(np.trace(expm(t*X[p[0]])@Q[p[0]]@expm(t*X[p[1]])@Q[p[1]]@(expm(t*X[p[2]])@Q[p[2]]).conj().T@(expm(t*X[p[3]])@Q[p[3]]).conj().T).real for p,_,_ in PL)\n eps=1e-3; fd=(S(eps)-2*S(0)+S(-eps))/eps**2\n tot2=0; corner=0\n for p,c,_ in PL:\n Q1,Q2,Q3,Q4=(Q[e] for e in p); W=Q1@Q2@Q3.conj().T@Q4.conj().T\n Y=[X[p[0]],Q1@X[p[1]]@Q1.conj().T,Q4@X[p[2]]@Q4.conj().T,X[p[3]]]\n tot2+=f2(Y,W)\n print(f\'U({N}): finite-difference Hessian {fd:.6f}, sum of plaquette forms {tot2:.6f}\')\n # end vectors: o at tail = X, i at head = Ad(Q^*)X\n end={}\n for (x,m) in edges:\n e=eidx[(x,m)]; end[(x,m)]=X[e]; end[(sh(x,m),4+m)]=Q[e].conj().T@X[e]@Q[e]\n lhs=0\n for (p,c,_) in PL:\n Q1,Q2,Q3,Q4=(Q[e] for e in p); W=Q1@Q2@Q3.conj().T@Q4.conj().T\n Y=[X[p[0]],Q1@X[p[1]]@Q1.conj().T,Q4@X[p[2]]@Q4.conj().T,X[p[3]]]\n vals=[ip(Y[0],Y[3]),ip(Y[0],Y[1]),ip(Y[1],W@Y[2]@W.conj().T),ip(Y[2],Y[3])]\n for (s,r,q),v in zip(c,vals): lhs+=2*float(G[s][r][q])*v\n rhs=sum(float(G[y][r][q])*ip(end[(y,r)],end[(y,q)]) for y in sites for r in range(8) for q in range(8) if r!=q)\n print(f\'U({N}): sum of corner terms {lhs:.10f}, site forms minus diagonals {rhs:.10f}\')\n a,b=(int(sys.argv[2]),int(sys.argv[3])) if len(sys.argv)>3 else (0,96); t0=time.time(); allok=True\n for j in range(a,b):\n ok,dep,tot,lm=run(j); allok&=ok\n print(f\'plaquette {j:2d}: {"positive definite" if ok else "FAILED"}, depth {dep}, cells {tot}, least eigenvalue at centres {lm:.6f}, {time.time()-t0:.0f}s\',flush=True)\n print(f\'plaquettes {a}..{b-1} positive definite\' if allok else \'FAILURE\')\n', 'sharp.py': '#!/usr/bin/env python3\n"""Sharpened plaquette-block constant alpha(beta_W) = 40 |beta| K for SU(2), in ball arithmetic.\n\ng(c) = log Z0(c) = phi(|c|^2) with Z0(c) = sum_j (|c|^2/4)^j / (j! (j+1)!), the normalisation of\nthe von Mises-Fisher law on S^3 = SU(2). On the ball |c| <= R the program encloses\n\n lambda_* <= every eigenvalue of Hess g, tau >= every eigenvalue of Hess g,\n M >= the operator norm of D^3 g, A >= |grad g(c)| = |c| 2 phi\'(|c|^2) on |c| <= R20,\n\nby python-flint at 128 bits on a subdivision of the radius, with the series of phi and its first\nthree derivatives summed to J terms and the tail bounded by twice the first omitted term (the\nterms decrease by a factor below one half on the whole ball). The eigenvalues of Hess g at c are\n2 phi\' (tangential, multiplicity three) and 2 phi\' + 4 |c|^2 phi\'\' (radial); D^3 g has norm at most\nmax(|A + G|, 2|A|/3) with A = 12 r phi\'\' and G = 8 r^3 phi\'\'\'.\n\nThe chain of the paper (Lemma onesite (ii) with the exponents interpolated, and the Poincare\nconstant 1/3 of the von Mises-Fisher law):\n\n w = 8 beta^2 (tau - lambda_*), s = 1/4 + (e^w - 1) e^w sqrt(tau/3),\n C = 4 |beta| s A + (320/3) |beta|^3 M e^w, K = (1 + |beta|) s / (1 - C), alpha = 40 |beta| K,\n\nwith beta = beta_W / 4. The old chain (s with sqrt(tau), C = 20|beta|(4|beta| tau s + 16 beta^2 M))\nis available as --mode paper. With --lean the four constants are rounded outward to 10^-12 and\nwritten as Lean definitions for lean/BlockCheck.lean.\n\n python3 sharp.py --n 200000 --lean lean/BlockData.lean 1/3 0.345 0.35 0.351\n"""\nimport argparse\nimport time\nfrom fractions import Fraction\n\nfrom flint import arb, ctx\n\nctx.prec = 128\nJ = 48\n\n\ndef coeffs(m):\n """S^(m)(t) = sum_{j >= m} t^(j-m) / (4^j (j-m)! (j+1)!) for S(t) = sum_j t^j / (4^j j! (j+1)!)."""\n return [arb(1) / (arb(4) ** j * arb.fac_ui(j - m) * arb.fac_ui(j + 1)) for j in range(m, J)]\n\n\nCOEF = [coeffs(m) for m in range(4)]\n\n\ndef tail(m, T):\n """bound for the omitted terms j >= J of the m-th derivative series on 0 <= t <= T."""\n term = arb(T) ** (J - m) / (arb(4) ** J * arb.fac_ui(J - m) * arb.fac_ui(J + 1))\n ratio = arb(T) / (4 * (J - m + 1) * (J + 2))\n assert ratio.upper() < 0.5\n return 2 * term\n\n\ndef horner(cs, t):\n s = arb(0)\n for c in reversed(cs):\n s = s * t + c\n return s\n\n\ndef phis(t, T):\n S = [horner(COEF[m], t) + arb(0, tail(m, T).upper()) for m in range(4)]\n p1 = S[1] / S[0]\n p2 = S[2] / S[0] - p1 * p1\n p3 = S[3] / S[0] - 3 * S[2] * S[1] / (S[0] * S[0]) + 2 * p1 ** 3\n return p1, p2, p3\n\n\ndef ball(lo, hi):\n lo, hi = arb(lo), arb(hi)\n return arb((lo + hi) / 2, ((hi - lo) / 2).upper())\n\n\ndef constants(R, R20, n):\n R = arb(R)\n T = (R * R).upper() * 1.0001\n lam = tau = M = A = None\n for k in range(n):\n rlo = R * k / n if k else arb(0)\n rhi = R * (k + 1) / n\n r = ball(rlo.lower(), rhi.upper())\n t = ball(arb(rlo.lower()) ** 2, arb(rhi.upper()) ** 2)\n p1, p2, p3 = phis(t, T)\n assert p2.upper() <= 0, "phi\'\' must be nonpositive"\n tan = 2 * p1\n rad = 2 * p1 + 4 * t * p2\n lo = min(tan.lower(), rad.lower())\n hi = max(tan.upper(), rad.upper())\n a3 = 12 * r * p2\n g3 = 8 * r ** 3 * p3\n d3 = max(abs(a3 + g3).upper(), (2 * abs(a3) / 3).upper())\n lam = lo if lam is None else min(lam, lo)\n tau = hi if tau is None else max(tau, hi)\n M = d3 if M is None else max(M, d3)\n if r.lower() <= arb(R20).upper():\n a = (r * tan).upper()\n A = a if A is None else max(A, a)\n return lam, tau, M, A\n\n\ndef chain(bW, consts, mode):\n lam, tau, M, A = consts\n b = abs(arb(bW)) / 4\n w = 8 * b * b * (tau - lam)\n ew = w.exp()\n if mode == "paper":\n s = arb(1) / 4 + (ew - 1) * ew * tau.sqrt()\n C = 20 * b * (4 * b * tau * s + 16 * b * b * M)\n else:\n s = arb(1) / 4 + (ew - 1) * ew * (tau / 3).sqrt()\n C = 4 * b * s * A + arb(320) / 3 * b ** 3 * M * ew\n assert C.upper() < 1\n K = (1 + b) * s / (1 - C)\n return w.upper(), s.upper(), C.upper(), K.upper(), (40 * b * K).upper()\n\n\ndef show(x):\n return x.str(10, radius=False)\n\n\ndef parse(bW):\n f = Fraction(bW)\n return arb(f.numerator) / arb(f.denominator)\n\n\ndef rnd(x, up, D=10 ** 12):\n y = x * D\n return int((y.ceil() if up else y.floor()).unique_fmpz())\n\n\ndef write_lean(path, lam, tau, M, A):\n vals = [("lamLo", rnd(lam, False), "lower bound for every eigenvalue of Hess g on |c| <= 24 beta"),\n ("tauHi", rnd(tau, True), "upper bound for every eigenvalue of Hess g on |c| <= 24 beta"),\n ("mHi", rnd(M, True), "upper bound for the norm of D^3 g on |c| <= 24 beta"),\n ("aHi", rnd(A, True), "upper bound for |grad g(c)| on |c| <= 20 beta")]\n lines = ["/- Written by sharp.py: Arb enclosures rounded outward, denominator 10^12. -/", "",\n "def den : Nat := 1000000000000"]\n for name, v, doc in vals:\n lines += [f"/-- {doc} -/", f"def {name} : Nat := {v}"]\n with open(path, "w") as fh:\n fh.write("\\n".join(lines) + "\\n")\n return [v for _, v, _ in vals]\n\n\ndef main():\n ap = argparse.ArgumentParser()\n ap.add_argument("--mode", choices=["paper", "sharp"], default="sharp")\n ap.add_argument("--n", type=int, default=200000)\n ap.add_argument("--ball", default=None, help="radius of the ball (default 24 beta of the last coupling)")\n ap.add_argument("--lean", default=None)\n ap.add_argument("betaW", nargs="+")\n a = ap.parse_args()\n bmax = parse(a.betaW[-1]) / 4\n R = parse(a.ball) if a.ball else 24 * bmax\n R20 = 20 * bmax\n t0 = time.time()\n lam, tau, M, A = constants(R, R20, a.n)\n print(f"# mode={a.mode} ball r <= {show(R.upper())} subintervals={a.n} terms={J} prec={ctx.prec} [{time.time()-t0:.1f}s]")\n print(f"# lambda_* >= {show(lam)} tau <= {show(tau)} M <= {show(M)} A(|c| <= {show(R20.upper())}) <= {show(A)}")\n consts = (lam, tau, M, A)\n if a.lean:\n rounded = write_lean(a.lean, lam, tau, M, A)\n D = 10 ** 12\n consts = tuple(arb(v) / D for v in rounded)\n print(f"# wrote {a.lean}: {rounded}")\n for bW in a.betaW:\n w, s, C, K, al = chain(parse(bW), consts, a.mode)\n print(f"beta_W={bW}: w<={show(w)} s<={show(s)} C<={show(C)} K<={show(K)} alpha<={show(al)} "\n + ("alpha < 1" if al < 1 else "FAILS"))\n\n\nif __name__ == "__main__":\n main()\n', 'slice/composite_free.py': '"""Slice ratio for composite, gauge-invariant slice fields of the free lattice gauge field.\n\nRemark freeslice of the forest paper treats the linear field. The slice field of Sec.\n"Renormalised flowed observables" is a gauge-invariant function of the spatial links of one\nslice, composed with the spatial flow. Its free (abelian, one colour; N^2-1 colours multiply D by\nN^2-1) analogue is the magnetic energy Phi_B(n) = sum_x sum_{i(p) = (d_mu db_rho dl_{nu sigma} - d_mu db_sigma dl_{nu rho}\n - d_nu db_rho dl_{mu sigma} + d_nu db_sigma dl_{mu rho}) / |d|^2;\nthe numerator is c_{-1} e^{-i th} + c_0 + c_1 e^{i th} in the time momentum th, and the inverse\nFourier transform of 1/(2 - 2cos th + m^2) is K(n) = e^{-w|n|}/(2 sinh w), cosh w = 1 + m^2/2,\nso Gt(n) = sum_j c_j K(n+j) exactly. For the magnetic field the numerator does not depend on th.\n\nThe continuum reference is the same sum over the momenta 2 pi n/ell of the torus of side ell,\nwith Gt(r,p) = N(p0 = i|p|) e^{-|p| r}/(2|p|) for r > 0; the infinite-volume continuum value is\nalso printed. Without the flow the continuum ratio is (r/r\')^5 for both fields.\n\n python3 composite_free.py\n"""\nimport itertools\n\nimport numpy as np\n\nSPACE = [(1, 2), (1, 3), (2, 3)]\nALL = [(m, n) for m in range(4) for n in range(m + 1, 4)]\n\n\ndef numer(d, db, mu, nu, rho, sg):\n dl = lambda a, b: 1.0 if a == b else 0.0\n return (d[:, mu] * db[:, rho] * dl(nu, sg) - d[:, mu] * db[:, sg] * dl(nu, rho)\n - d[:, nu] * db[:, rho] * dl(mu, sg) + d[:, nu] * db[:, sg] * dl(mu, rho))\n\n\ndef D_lattice(L, ns, tf_lat, pairs):\n """D(n) for n in ns on an L^3 spatial torus (lattice units), spatial flow time tf_lat."""\n k = 2 * np.pi * np.fft.fftfreq(L)\n p = np.stack(np.meshgrid(k, k, k, indexing="ij"), -1).reshape(-1, 3)\n p = p[np.any(p != 0, axis=1)]\n ds = np.exp(1j * p) - 1.0\n m2 = np.sum(np.abs(ds) ** 2, axis=1)\n w = np.arccosh(1 + m2 / 2)\n flow = np.exp(-2 * tf_lat * m2)\n K = lambda n: np.exp(-w * np.abs(n)) / (2 * np.sinh(w))\n ths = 2 * np.pi * np.arange(3) / 3\n ds_all = [np.concatenate([np.full((len(p), 1), np.exp(1j * th) - 1), ds], axis=1) for th in ths]\n out = np.zeros(len(ns))\n for (mu, nu), (rho, sg) in itertools.product(pairs, pairs):\n vals = np.array([numer(d, np.conj(d), mu, nu, rho, sg) for d in ds_all])\n c = {j: np.mean(vals * np.exp(-1j * j * ths)[:, None], axis=0) for j in (-1, 0, 1)}\n for i, n in enumerate(ns):\n out[i] += np.sum(np.abs(sum(c[j] * K(n + j) for j in (-1, 0, 1)) * flow) ** 2)\n return 2 * out / L ** 3\n\n\ndef D_continuum(ell, rs, tf, pairs, nmax=None):\n """D(r) for r > 0 in the continuum; ell = None is infinite volume (angular average, then a\n radial quadrature), otherwise the torus of side ell."""\n if ell is None:\n rng = np.random.default_rng(0)\n u = rng.normal(size=(20000, 3))\n u /= np.linalg.norm(u, axis=1, keepdims=True)\n d = np.concatenate([-np.ones((len(u), 1)), 1j * u], axis=1)\n db = np.concatenate([np.ones((len(u), 1)), -1j * u], axis=1)\n S = sum(np.abs(numer(d, db, *a, *b)) ** 2 for a, b in itertools.product(pairs, pairs)).mean()\n q = np.linspace(1e-4, 80, 40001)\n return np.array([np.trapezoid(S * q ** 4 / 4 * np.exp(-2 * q * r - 4 * tf * q * q), q)\n for r in rs]) * 2 / (2 * np.pi ** 2)\n nmax = nmax or int(ell * 10)\n k = 2 * np.pi * np.arange(-nmax, nmax + 1) / ell\n p = np.stack(np.meshgrid(k, k, k, indexing="ij"), -1).reshape(-1, 3)\n p = p[np.any(p != 0, axis=1)]\n w = np.linalg.norm(p, axis=1)\n d = np.concatenate([(-w)[:, None], 1j * p], axis=1) # d_0 = i p0 at p0 = i|p|\n db = np.concatenate([w[:, None], -1j * p], axis=1) # conjugate taken before continuation\n S = sum(np.abs(numer(d, db, *a, *b)) ** 2 for a, b in itertools.product(pairs, pairs))\n return np.array([np.sum(S * np.exp(-2 * w * r - 4 * tf * w * w) / (4 * w * w)) for r in rs]) * 2 / ell ** 3\n\n\ndef main():\n rs = np.array([0.25, 0.5, 1.0])\n ell = 6.0\n for name, pairs, spacings in (("magnetic (the paper\'s slice field)", SPACE, (8, 12, 16, 24)),\n ("electric + magnetic", ALL, (8, 12, 16))):\n print(f"== {name}")\n for tf in (0.05, 0.0):\n Di = D_continuum(None, rs, tf, pairs)\n Df = D_continuum(ell, rs, tf, pairs)\n print(f"t_f = {tf}: continuum D(.5)/D(.25), D(1)/D(.5) = {Di[1]/Di[0]:.5f}, {Di[2]/Di[1]:.5f}"\n f" (infinite volume); {Df[1]/Df[0]:.5f}, {Df[2]/Df[1]:.5f} (side {ell})", flush=True)\n for inv_a in spacings:\n L = int(ell * inv_a)\n ns = np.array([0, 1] + [int(round(r * inv_a)) for r in rs])\n D = D_lattice(L, ns, tf * inv_a ** 2, pairs)\n print(f" 1/a={inv_a:3d} L={L:3d}: D(.5)/D(.25)={D[3]/D[2]:.5f} D(1)/D(.5)={D[4]/D[3]:.5f}"\n f" D(a)/D(0)={D[1]/D[0]:.4f} D(.25)/D(0)={D[2]/D[0]:.3e}", flush=True)\n\n\nif __name__ == "__main__":\n main()\n', 'slice/normal_order.py': "# Normal-ordered form of L^3, L = -d^2 + x^2 + 4 in one variable, as\n# sum c_{ab} x^a d^b (x to the left), in exact integer arithmetic, and the\n# constant sum_{k>=0} (2k+5)^(-7/4) used in Lemma lem:hermite (mpmath iv).\nfrom math import comb, factorial\nfrom collections import defaultdict\ndef mul(A,B):\n C=defaultdict(int)\n for (a,b),u in A.items():\n for (c,d),v in B.items():\n for j in range(0,min(b,c)+1):\n C[(a+c-j,b-j+d)]+=u*v*comb(b,j)*factorial(c)//factorial(c-j)\n return {k:v for k,v in C.items() if v}\nL={(0,2):-1,(2,0):1,(0,0):4}\nL3=mul(L,mul(L,L))\nprint(sorted(L3.items()))\nlam=sum(abs(v) for v in L3.values())\nprint('lambda =',lam)\nprint('max a, max b =',max(a for a,b in L3),max(b for a,b in L3))\nfrom mpmath import iv, mpf\niv.dps=30\n# sum_{k>=0}(2k+5)^(-7/4) <= 5^(-7/4) + int_0^inf (2x+5)^(-7/4) dx = 5^(-7/4) + (2/3) 5^(-3/4)\ns=iv.mpf(5)**(iv.mpf(-7)/4)+iv.mpf(2)/3*iv.mpf(5)**(iv.mpf(-3)/4)\nprint('sum bound =',s)\nprint('pi*sum bound =',iv.pi*s)\n", 'small_field_fibre.py': '"""Checks of the small-field estimates on the fibres of the cut-off average\n(Theorem thm:smallfibre and Lemma lem:smallframes of the forest paper,\nSec. ssec:smallfibres), for G = SU(2) on the periodic lattice of side 4.\n\nThe background fields are U = h . exp(eps X) in the tree gauge: X is a\nrandom field on the active links, the tree links are I, and h is a random\ngauge transformation that is constant on every block, so the links between\nblocks are far from I while every plaquette has angle of order eps. For\neps = 1e-3, 1e-2 and 3e-2, and for W = all sixteen blocks and W = eight of\nthem, the program\n\n (a) checks the local bounds delta(U_e, I) <= 3 kappa on the active links\n inside the blocks and delta(U_a, v) <= 21 kappa on the links leaving\n a block, kappa being the largest plaquette distance;\n (b) checks the frame estimates of the lemma: the covariant curvature of an\n inner plaquette differs from the flat one by at most 18 kappa times\n the sum of the link norms, that of a face plaquette, in the frame of\n the next block, by at most 48 kappa times it, and the right-trivialised\n derivative of the cut-off average differs from the block average of\n the framed field by at most 260 kappa N_{y,mu} (operator norms, the\n derivative computed by central differences);\n (c) computes the tangent space of the fibre and the least value of\n Q_U(xi)/|xi|^2 on it, which the theorem bounds below by\n 1/(52(1 + 1.4e6 kappa)) for kappa <= 1e-8 (the block gap of the\n quadratic approximation is 0.1075);\n (d) assembles the Hessian of Q along the geodesics U exp(t xi) from the\n formula of the proof, compares it with second differences, and checks\n Hess Q >= 2 Q_U - 84 kappa |xi|^2 for every xi (least eigenvalue);\n (e) checks the gradient bound |grad_e Q| <= 12 kappa, the Gram bound\n DC DC^* >= 1/16 - 700 kappa, and evaluates the Hessian of Q on the\n fibre, Hess Q + dQ(eta) with eta the normal acceleration, at random\n tangent vectors and at the least direction of (c), checking that the\n fibre curve U exp(t xi + t^2 eta / 2) stays on the fibre to third\n order.\n\nThese are floating-point checks of the inequalities of the proof at fields\nfar larger than the kappa <= 1e-8 of the theorem; they are not interval\ncertificates.\n\nUsage: python3 small_field_fibre.py\n"""\n\nimport itertools\n\nimport numpy as np\n\nchecks = []\n\n\ndef check(name, ok):\n checks.append((name, bool(ok)))\n print(("PASS " if ok else "FAIL ") + name)\n\n\nL = 4\nDIM = 4\nSIG = [np.array([[0, 1], [1, 0]], complex),\n np.array([[0, -1j], [1j, 0]], complex),\n np.array([[1, 0], [0, -1]], complex)]\nTAU = [1j * s / np.sqrt(2) for s in SIG] # orthonormal in the HS norm\nI2 = np.eye(2, dtype=complex)\n\n\ndef alg(c):\n return sum(c[k] * TAU[k] for k in range(3))\n\n\ndef coords(X):\n return np.array([np.real(np.trace(TAU[k].conj().T @ X)) for k in range(3)])\n\n\ndef expm(c):\n a = np.asarray(c) / np.sqrt(2)\n th = np.linalg.norm(a)\n if th < 1e-300:\n return I2.copy()\n n = a / th\n return np.cos(th) * I2 + 1j * np.sin(th) * sum(n[k] * SIG[k] for k in range(3))\n\n\ndef logm(g):\n a0 = np.real(np.trace(g)) / 2\n b = np.array([np.real(np.trace(-1j * SIG[k] @ g)) / 2 for k in range(3)])\n nb = np.linalg.norm(b)\n th = np.arctan2(nb, a0)\n if nb < 1e-300:\n return np.zeros(3)\n return np.sqrt(2) * th * b / nb # coordinates in TAU\n\n\ndef dist(a, b):\n return np.linalg.norm(a - b)\n\n\ndef ad(g):\n R = np.zeros((3, 3))\n for l in range(3):\n R[:, l] = coords(g @ TAU[l] @ g.conj().T)\n return R\n\n\ndef e(mu):\n v = [0] * DIM\n v[mu] = 1\n return tuple(v)\n\n\ndef add(x, y):\n return tuple((x[i] + y[i]) % L for i in range(DIM))\n\n\ndef sub(x, y):\n return tuple((x[i] - y[i]) % L for i in range(DIM))\n\n\nSITES = list(itertools.product(range(L), repeat=DIM))\nBLOCKS = list(itertools.product(range(L // 2), repeat=DIM))\n\n\ndef off(x):\n return tuple(c % 2 for c in x)\n\n\ndef blk(x):\n return tuple(c // 2 for c in x)\n\n\ndef is_tree(x, mu):\n o = off(x)\n return o[mu] == 0 and all(o[n] == 0 for n in range(mu + 1, DIM))\n\n\ndef make_field(eps, rng):\n U = {}\n h = {y: expm(rng.normal(size=3) * 3) for y in BLOCKS}\n for x in SITES:\n for mu in range(DIM):\n if is_tree(x, mu):\n g = I2.copy()\n else:\n g = expm(rng.normal(size=3) * eps)\n U[(x, mu)] = h[blk(x)] @ g @ h[blk(add(x, e(mu)))].conj().T\n return U\n\n\nPLAQ = [(x, mu, nu) for x in SITES for mu in range(DIM) for nu in range(mu + 1, DIM)]\n\n\ndef plinks(p):\n x, mu, nu = p\n return [(x, mu), (add(x, e(mu)), nu), (add(x, e(nu)), mu), (x, nu)]\n\n\ndef hol(U, p):\n l1, l2, l3, l4 = (U[l] for l in plinks(p))\n return l1 @ l2 @ l3.conj().T @ l4.conj().T\n\n\ndef dmaps(U, p):\n """3x3 blocks A_i with D_p = sum_i A_i xi_i (coordinates)."""\n l1, l2, l3, l4 = (U[l] for l in plinks(p))\n g1, g2, g4 = l1, l1 @ l2, l1 @ l2 @ l3.conj().T\n return [ad(g1), ad(g2), -ad(g2), -ad(g4)]\n\n\ndef vsharp(U, y, mu):\n root = tuple(2 * c for c in y)\n P = U[(root, mu)] @ U[(add(root, e(mu)), mu)]\n Ms = []\n mx = 0.0\n for o in itertools.product((0, 1), repeat=DIM):\n x = add(root, o)\n Px = U[(x, mu)] @ U[(add(x, e(mu)), mu)]\n mx = max(mx, dist(Px, P))\n Ms.append(logm(P.conj().T @ Px))\n assert mx <= 0.5, "outside the small-field branch"\n return P @ expm(np.mean(Ms, axis=0)), P\n\n\ndef vlinks(y, mu):\n """The 24 active-or-tree links entering V_{y,mu} with their weights."""\n root = tuple(2 * c for c in y)\n out = {}\n for o in itertools.product((0, 1), repeat=DIM):\n x = add(root, o)\n for z in (x, add(x, e(mu))):\n out[(z, mu)] = out.get((z, mu), 0) + 1 / 16\n return out\n\n\ndef run(eps, Wfrac, seed):\n rng = np.random.default_rng(seed)\n U = make_field(eps, rng)\n kappa = max(dist(hol(U, p), I2) for p in PLAQ)\n W = BLOCKS if Wfrac == 1 else [y for y in BLOCKS if sum(y) % 2 == 0]\n Wset = set(W)\n tag = f"eps={eps:g}, |W|={len(W)}, kappa={kappa:.3e}"\n print(f"-- {tag}")\n\n # (a) local bounds\n inner = [(x, mu) for x in SITES for mu in range(DIM)\n if not is_tree(x, mu) and off(x)[mu] == 0]\n ok_in = max(dist(U[l], I2) for l in inner) <= 3 * kappa\n ok_out = True\n for y in BLOCKS:\n root = tuple(2 * c for c in y)\n for mu in range(DIM):\n v = U[(add(root, e(mu)), mu)]\n for a in itertools.product((0, 1), repeat=DIM):\n if a[mu] == 1:\n ok_out &= dist(U[(add(root, a), mu)], v) <= 21 * kappa\n check(f"(a) inner links <= 3 kappa, leaving links within 21 kappa of v ({tag})",\n ok_in and ok_out)\n\n # variables\n var = [(x, mu) for x in SITES for mu in range(DIM)\n if not is_tree(x, mu) and blk(x) in Wset]\n vid = {l: i for i, l in enumerate(var)}\n n = 3 * len(var)\n\n # (b) frame estimates for plaquettes; assemble D\n rows = []\n ok_inner, ok_face = True, True\n worst_in, worst_face = 0.0, 0.0\n plist = [p for p in PLAQ if any(l in vid for l in plinks(p))]\n D = np.zeros((3 * len(plist), n))\n for r, p in enumerate(plist):\n A = dmaps(U, p)\n ls = plinks(p)\n for i, l in enumerate(ls):\n if l in vid:\n D[3 * r:3 * r + 3, 3 * vid[l]:3 * vid[l] + 3] += A[i]\n x, mu, nu = p\n bl = [blk(l[0]) for l in ls] + [blk(add(l[0], e(l[1]))) for l in ls]\n if len(set(bl)) == 1:\n sgn = [1, 1, -1, -1]\n err = max(np.linalg.norm(A[i] - sgn[i] * np.eye(3), 2) for i in range(4))\n worst_in = max(worst_in, err / kappa)\n ok_inner &= err <= 18 * kappa + 1e-12\n else:\n # face plaquette: the two links in the direction that leaves\n for lead, tran in ((mu, nu), (nu, mu)):\n if off(x)[lead] == 1 and blk(add(x, e(lead))) != blk(x) \\\n and blk(add(x, e(tran))) == blk(x):\n y = blk(x)\n root = tuple(2 * c for c in y)\n v = U[(add(root, e(lead)), lead)]\n Rv = ad(v.conj().T)\n Bk = [Rv @ Ai for Ai in A]\n if lead == mu:\n want = [np.eye(3), np.eye(3), -np.eye(3), -Rv]\n else: # orientation reversed: compare with the inverse\n Up = hol(U, p)\n Bk = [-ad(v.conj().T @ Up.conj().T) @ Ai for Ai in A]\n # links: (x,nu) in B(y), (x+nu,mu) leaving, (x+mu,nu) next block, (x,mu) leaving\n want = [-Rv, -np.eye(3), np.eye(3), np.eye(3)]\n err = max(np.linalg.norm(Bk[i] - want[i], 2) for i in range(4))\n worst_face = max(worst_face, err / kappa)\n ok_face &= err <= 48 * kappa + 1e-12\n check(f"(b) inner plaquettes within 18 kappa (worst {worst_in:.2f} kappa) ({tag})", ok_inner)\n check(f"(b) face plaquettes within 48 kappa in the next frame (worst {worst_face:.2f} kappa) ({tag})", ok_face)\n\n # constraint derivatives\n cons = [(y, mu) for y in W for mu in range(DIM)]\n DC = np.zeros((3 * len(cons), n))\n t = 1e-6\n worst_c = 0.0\n hfun = []\n for k, (y, mu) in enumerate(cons):\n V0, v = vsharp(U, y, mu)\n wts = vlinks(y, mu)\n Bt = np.zeros((3, n))\n Rv = ad(v.conj().T)\n for l, wgt in wts.items():\n if l not in vid:\n continue\n (z, _) = l\n frame = Rv if blk(z) == y and off(z)[mu] == 0 else np.eye(3)\n Bt[:, 3 * vid[l]:3 * vid[l] + 3] += wgt * frame\n for c in range(3):\n old = U[l]\n d = np.zeros(3)\n d[c] = t\n U[l] = old @ expm(d)\n Vp, _ = vsharp(U, y, mu)\n U[l] = old @ expm(-d)\n Vm, _ = vsharp(U, y, mu)\n U[l] = old\n DC[3 * k:3 * k + 3, 3 * vid[l] + c] = (logm(V0.conj().T @ Vp) - logm(V0.conj().T @ Vm)) / (2 * t)\n cols = [3 * vid[l] + c for l in wts if l in vid for c in range(3)]\n R = (DC[3 * k:3 * k + 3] - Bt)[:, cols]\n err = np.linalg.norm(R, 2)\n worst_c = max(worst_c, err / kappa)\n check(f"(b) linearised constraint within 260 kappa of the block average (worst {worst_c:.2f} kappa) ({tag})",\n worst_c <= 260)\n\n # (c) tangent space and covariant gap\n _, s, Vt = np.linalg.svd(DC)\n rank = int(np.sum(s > 1e-8))\n Nb = Vt[rank:].T\n QU = D.T @ D\n lam = np.linalg.eigvalsh(Nb.T @ QU @ Nb)[0]\n check(f"(c) DC has full rank {rank} = {3 * len(cons)}", rank == 3 * len(cons))\n check(f"(c) least Q_U/|xi|^2 on the tangent space = {lam:.6f} >= 1/52", lam >= 1 / 52)\n\n # (d) Hessian of Q along U exp(t xi)\n H = np.zeros((n, n))\n grad = np.zeros(n)\n ok_g = True\n gl = np.zeros((len(var), 3))\n for r, p in enumerate(plist):\n ls = plinks(p)\n Up = hol(U, p)\n A = dmaps(U, p)\n idx = [vid.get(l) for l in ls]\n w = np.array([-2 * np.real(np.trace(TAU[k] @ (Up - I2))) for k in range(3)])\n for i in range(4):\n if idx[i] is not None:\n g = A[i].T @ w\n grad[3 * idx[i]:3 * idx[i] + 3] += g\n gl[idx[i]] += g\n\n def q(c12):\n Bs = [alg(A[i] @ c12[3 * i:3 * i + 3]) for i in range(4)]\n Dm = sum(Bs)\n C = sum(Bs[i] @ Bs[j] - Bs[j] @ Bs[i] for i in range(4) for j in range(i + 1, 4))\n return -2 * np.real(np.trace((Dm @ Dm + C) @ Up))\n act = [3 * i + c for i in range(4) if idx[i] is not None for c in range(3)]\n glob = [3 * idx[i] + c for i in range(4) if idx[i] is not None for c in range(3)]\n E = np.eye(12)\n qd = {a: q(E[a]) for a in act}\n for ia, a in enumerate(act):\n for ib, b in enumerate(act):\n if ib < ia:\n continue\n val = qd[a] if a == b else (q(E[a] + E[b]) - qd[a] - qd[b]) / 2\n H[glob[ia], glob[ib]] += val\n if ia != ib:\n H[glob[ib], glob[ia]] += val\n ok_g = np.max(np.linalg.norm(gl, axis=1)) <= 12 * kappa\n check(f"(e) gradient bound |grad_e Q| <= 12 kappa ({tag})", ok_g)\n\n def Qval(Uf):\n return sum(dist(hol(Uf, p), I2) ** 2 for p in plist)\n\n def moved(X):\n Uf = dict(U)\n for l, i in vid.items():\n Uf[l] = U[l] @ expm(X[3 * i:3 * i + 3])\n return Uf\n xi = rng.normal(size=n)\n xi /= np.linalg.norm(xi)\n h = 1e-3\n fd = (Qval(moved(h * xi)) - 2 * Qval(U) + Qval(moved(-h * xi))) / h ** 2\n fd1 = (Qval(moved(h * xi)) - Qval(moved(-h * xi))) / (2 * h)\n check(f"(d) Hessian formula agrees with second differences ({xi @ H @ xi:.6f} vs {fd:.6f})",\n abs(xi @ H @ xi - fd) <= 1e-4)\n check(f"(e) gradient formula agrees with first differences ({grad @ xi:.3e} vs {fd1:.3e})",\n abs(grad @ xi - fd1) <= 1e-6 + 1e-4 * abs(fd1))\n mineig = np.linalg.eigvalsh(H - 2 * QU + 84 * kappa * np.eye(n))[0]\n check(f"(d) Hess Q >= 2 Q_U - 84 kappa |xi|^2 (least eigenvalue {mineig:.3e}) ({tag})", mineig >= -1e-9)\n hmin = np.linalg.eigvalsh(Nb.T @ H @ Nb)[0]\n check(f"(d) least ambient Hessian on the tangent space {hmin:.5f} >= 1/26 - 5.4e4 kappa",\n hmin >= 1 / 26 - 5.4e4 * kappa)\n\n # (e) Gram matrix and fibre Hessian\n G = DC @ DC.T\n gmin = np.linalg.eigvalsh(G)[0]\n check(f"(e) Gram matrix >= 1/16 - 700 kappa (least eigenvalue {gmin:.5f})", gmin >= 1 / 16 - 700 * kappa)\n\n def Cvals(X):\n Uf = moved(X)\n out = []\n for (y, mu) in cons:\n V0, _ = vsharp(U, y, mu)\n V1, _ = vsharp(Uf, y, mu)\n out.append(logm(V0.conj().T @ V1))\n return np.concatenate(out)\n w_least = Nb @ np.linalg.eigh(Nb.T @ QU @ Nb)[1][:, 0]\n samples = [w_least] + [Nb @ rng.normal(size=Nb.shape[1]) for _ in range(3)]\n ratios = []\n ok_curve = True\n for s_ in samples:\n s_ = s_ / np.linalg.norm(s_)\n hh = 1e-3\n hvec = (Cvals(hh * s_) + Cvals(-hh * s_)) / hh ** 2\n eta = -DC.T @ np.linalg.solve(G, hvec)\n hf = s_ @ H @ s_ + grad @ eta\n ratios.append(hf)\n tt = 1e-2\n c3 = np.linalg.norm(Cvals(tt * s_ + tt ** 2 * eta / 2))\n ok_curve &= c3 <= 50 * tt ** 3\n check(f"(e) fibre curves stay on the fibre to third order ({tag})", ok_curve)\n check(f"(e) fibre Hessian of Q at the least and three random tangent directions: "\n f"{\', \'.join(f\'{r:.5f}\' for r in ratios)} (all >= 1/26 - 5.4e4 kappa - 1e3 kappa)",\n min(ratios) >= 1 / 26 - 5.5e4 * kappa)\n return kappa, lam\n\n\ndef constants():\n from fractions import Fraction as F\n k = F(1, 10 ** 8)\n check("constants: 3888*8 = 31104", 3888 * 8 == 31104)\n check("constants: 8*260^2 = 540800, 2*540800 + 3*4608 = 1095424 <= 1.1e6",\n 8 * 260 ** 2 == 540800 and 2 * 540800 + 3 * 4608 == 1095424 <= 1100000)\n check("constants: (13/2)*31104 + 1.1e6 <= 1.31e6", F(13, 2) * 31104 + 1100000 <= 1310000)\n check("constants: 52(1+k)^2/(1 - 1.31e6 k (1+k)^2) <= 52(1 + 1.4e6 k) at k = 1e-8",\n (1 + k) ** 2 / (1 - F(131, 100) * 10 ** 6 * k * (1 + k) ** 2) <= 1 + F(14, 10) * 10 ** 6 * k)\n check("constants: 2/(52(1+1.4e6 k)) - 84 k >= 1/26 - 5.4e4 k for k <= 1e-8",\n F(2, 52) / (1 + F(14, 10) * 10 ** 6 * k) - 84 * k >= F(1, 26) - 54000 * k)\n check("constants: 202 + 103*0.434 + 42/4 <= 260", 202 + 103 * 0.434 + 42 / 4 <= 260)\n check("constants: (1/16 + 454 k)/(1/8 - 227 k) <= 0.51 and 1/((1/8 - 227k)(0.49)) <= 17",\n (F(1, 16) + 454 * k) / (F(1, 8) - 227 * k) <= F(51, 100)\n and 1 / ((F(1, 8) - 227 * k) * F(49, 100)) <= 17)\n check("constants: 16 pi <= 50.3, e^(50.3k) - 1 <= 51 k, 51(1 + 50.3k) <= 51.6",\n 16 * np.pi <= 50.3 and np.expm1(50.3e-8) <= 51e-8 and 51 * (1 + 50.3e-8) <= 51.6)\n check("constants: 51 + 51.6 + 99 <= 202, 51.6 + 51 <= 103, sqrt(48)/16 <= 0.434",\n 51 + 51.6 + 99 <= 202 and 51.6 + 51 <= 103 and np.sqrt(48) / 16 <= 0.434)\n check("constants: sqrt(3/16) <= 0.434, 2*0.434*260 + 260^2 k <= 227",\n np.sqrt(3 / 16) <= 0.434 and 2 * 0.434 * 260 + 260 ** 2 * 1e-8 <= 227)\n check("constants: 1/8 - 227k - 2(1/32 + 227k) >= 1/16 - 700k",\n F(1, 8) - 227 * k - 2 * (F(1, 32) + 227 * k) >= F(1, 16) - 700 * k)\n check("constants: (0.434 + 260k) 12 sqrt(24) <= 26, 17*26 = 442, 2*442 = 884",\n (0.434 + 260e-8) * 12 * np.sqrt(24) <= 26 and 17 * 26 == 442)\n\n\nif __name__ == "__main__":\n constants()\n for eps, wf, seed in ((1e-3, 1, 1), (1e-3, 0, 2), (1e-2, 1, 3), (3e-2, 0, 4)):\n run(eps, wf, seed)\n n_ok = sum(ok for _, ok in checks)\n print(f"{n_ok} of {len(checks)} checks passed")\n', } if __name__ == "__main__": import os for name, text in FILES.items(): d = os.path.dirname(name) if d: os.makedirs(d, exist_ok=True) with open(name, "w") as f: f.write(text) print(len(FILES), "files written")