"""Job #44: read out-wc.txt (window-check.js 1e10) and out-zg10.txt (zonegap-01.js 1e10), extract the values the brief names, and compare every row whose scope overlaps the embedded runs (window-check embedded at 1e9, zonegap at 1e11). window-check: the decade rows 10^0..10^8 depend only on primes below 1e9 and their first twin above, so they must equal the embedded rows; the worst margin must stay >= 1 (falsifier). zonegap: envelope steps are A113274 records; every step the 1e10 run prints must equal the embedded step with the same record number; SHARED LEVELS (p <= 43) and the maxgap-law cross-check rows must be identical; per-band rows are compared and any difference is reported with the band's zone counts (a band cut by X differs by construction). stdout is deterministic. Run from the directory containing the input files and research/. Elapsed-time diagnostics go to stderr. """ import re, sys W = "./" def embedded(name): t = open(W + "research/" + name, encoding="utf-8").read() t = t[t.index("// OUTPUT"):] return "\n".join(l[3:] if l.startswith("// ") else l[2:] for l in t.splitlines() if l.startswith("//")) wc, wce = open(W + "out-wc.txt", encoding="utf-8").read(), embedded("window-check.js") zg, zge = open(W + "out-zg10.txt", encoding="utf-8").read(), embedded("zonegap-01.js") fails = 0 def line(pat, text): m = re.search(pat, text, re.M) value = m.group(0).strip() if m else "(not found)" result = re.sub(r"(?:\s+\[\d+(?:\.\d+)?s\]|,\s+\d+(?:\.\d+)?\s+s)$", "", value) if result != value: print(" " + value, file=sys.stderr) return result print("== window-check.js 1e10") for pat in [r"^checked every prime.*$", r"^WORST margin.*$", r"^\s*there the window.*$", r"^largest distance.*$", r"^VERDICT.*$", r"^still pending.*$"]: print(" " + line(pat, wc)) m = re.search(r"WORST margin = ([\d.]+)\s+at p = ([\d,]+)", wc) if not m or float(m.group(1)) < 1: fails += 1; print(" FALSIFIER: worst margin below 1 or not found") dec = lambda t: {int(k): v.strip() for k, v in re.findall(r"^\s*10\^\s*(\d+)\s*\|(.*)$", t, re.M)} dr, de = dec(wc), dec(wce) for k in sorted(dr): if k in de: same = re.sub(r"\s+", " ", dr[k]) == re.sub(r"\s+", " ", de[k]) fails += not same print(f" decade 10^{k}: {'SAME as embedded 1e9 row' if same else 'DIFFERS: run ' + dr[k] + ' | embed ' + de[k]}") else: print(f" decade 10^{k} (new at 1e10): {re.sub(chr(32)+'+', ' ', dr[k])}") print("\n== zonegap-01.js 1e10") for pat in [r"^ENGINE SELF-CHECK.*$", r"^\s*brute-force engine.*$", r"^CUSTODY 1.*$", r"^CUSTODY 2.*$", r"^\s*adopted Oliveira.*$", r"^CUSTODY 3.*$", r"^\s*p'\^2, verified.*$", r"^SWEEP.*$", r"^ZONE POSTULATE.*$", r"^THE MARGIN.*$", r"^\s*measured exponent.*$", r"^\s*separation.*$", r"^\s*ln\^2\*lnln candidate.*$", r"^\s*Oliveira e Silva first-occurrence envelope.*$", r"^\s*each zone's max-gap.*$", r"^THE HEAD.*$", r"^\s*height p\. Mean head.*$", r"^\s*worst head.*$", r"^\s*heights predicts.*$", r"^POSITION.*$", r"^\s*decile counts.*$", r"^\s*fractions.*$", r"^\s*mean u.*$"]: print(" " + line(pat, zg)) print(" " + line(r"^done in.*$", zg), file=sys.stderr) steps = lambda t: {int(r[4]): r for r in re.findall(r"^\s*(\d+)\s+(\d+)\s+(\d+)\s+([\d.]+)\s+(\d+)\s*$", t[t.index("ENVELOPE STEPS"):t.index("THE LAW")], re.M)} sr, se = steps(zg), steps(zge) bad = [k for k in sr if sr[k] != se.get(k)] fails += len(bad) last = sr[max(sr)] print(f" envelope steps: {len(sr)} printed at 1e10, each equal to the embedded step with the same record number: {not bad} {bad}") print(f" largest Z2 at 1e10: Z2 = {last[1]} in the zone of p = {last[0]} (gap start {last[2]}, u = {last[3]}, A113274 record {last[4]})") def block(t, start, end): s = t.index(start); e = t.index(end, s); return [re.sub(r"\s+", " ", l.strip()) for l in t[s:e].splitlines()[1:] if l.strip()] for start, end in [("SHARED LEVELS", "(Z2(p) <= G2"), ("maxgap-law.md", "THE HEAD")]: a, b = block(zg, start, end), block(zge, start, end) fails += a != b print(f" {start}: {len(a)} lines, identical to embedded: {a == b}") band = lambda t: {r[0]: r for r in (re.split(r"\s{2,}", l.strip()) for l in t[t.index("PER-BAND"):t.index("ENVELOPE STEPS")].splitlines() if re.match(r"\s*(10\^|1e5)", l)) if len(r) > 5} br, be = band(zg), band(zge) print(" per-band rows (run | embedded 1e11):") for k in br: same = br[k] == be.get(k) print(f" {' '.join(br[k])} {'SAME' if same else '| embed ' + ' '.join(be.get(k, ['(no such band)']))}") print(f"\n{'ALL OVERLAPPING ROWS AGREE' if fails == 0 else str(fails) + ' DIFFERENCES OR FALSIFIER'}") sys.exit(1 if fails else 0)