// q3_check.c : independent check for isitsolved question IIS-Q-0003 (28 November 2026). // The program builds the 112-caps from the design of Edel and Bierbrauer. // It uses no file of the author. Build: clang -O3 -o q3_check q3_check.c // Revision 2 (28 November 2026): the last report line prints the count of the candidates. In // revision 1 that count stayed 0. No other output changed. // Modes (L = 0 or 1 selects the thick layer of the 236-cap that is the cap A): // dump236 the 236 points, sorted // facts L structural facts of the cap and of its dual set // tables L TYPE BUDGETS [PART/N] with TYPE = intact | dual | p1w | p1s | p2 | p3 // masks L TYPE a [b [c]] prints 308 masks, one per line // cross L S is the other thick layer of the 236-cap // mono L [K] all 23040 signed permutation matrices; K prints the first matrix with overlap K // one L M [D] [DLIM] one invertible matrix M (36 digits, row by row); D = 1 prints a trace; // DLIM sets the limit for the full enumeration // pairs L SEED NSAMP [NDIR] [V] [DLIM] [MINC] NSAMP random matrices; NDIR prints the first NDIR samples; // V = 2 prints the matrix and the two methods; DLIM sets the limit for the // full enumeration; MINC keeps only the samples with at least MINC candidates // climb L SEED NCLIMB STEPS [K] local search for a large overlap; K is the least overlap #include #include #include #include typedef uint64_t u64; #define NV 729 #define MAXC 366 static int co[NV][6]; static int addt[NV][NV]; static int negt[NV]; static int repOf[NV], clsIdx[NV], reps[364], nrep; static int inB[NV], Bv[112], bIdx[NV], nb; static int R[56], Ridx[NV]; static int isD[NV], Dv[112], nd, DR[56], DRidx[NV]; static int EXT[308], extIdx[NV], next_; static int E1[308][10], E2[308][10], ne[308]; static u64 PM[308]; static const int blk[10][3] = {{0,1,2},{0,1,3},{0,2,4},{0,3,5},{0,4,5},{1,2,5},{1,3,4},{1,4,5},{2,3,4},{2,3,5}}; static int lead(int v){ int i=0; while(co[v][i]==0) i++; return i; } static int dot(int a,int b){ int s=0; for(int i=0;i<6;i++) s+=co[a][i]*co[b][i]; return s%3; } static int eq(const char *a,const char *b){ return strcmp(a,b)==0; } static void init(void) { for(int v=0;v=0&&x==b)||(c>=0&&x==c), py=(y==a)||(b>=0&&y==b)||(c>=0&&y==c); if(a<0){ m|=(1ULL<=Maxd||n==0) return; int *q=Q[lv]; for(int i=0;i>7; rs^=rs<<17; return rs; } static int rank6(int T[6][6]) { int M[6][6]; memcpy(M,T,sizeof M); int r=0; for(int c=0;c<6;c++){ int p=-1; for(int i=r;i<6;i++) if(M[i][c]){ p=i; break; } if(p<0) continue; if(p!=r) for(int j=0;j<6;j++){ int t=M[r][j]; M[r][j]=M[p][j]; M[p][j]=t; } int inv=(M[r][c]==1)?1:2; for(int j=c;j<6;j++) M[r][j]=M[r][j]*inv%3; for(int i=0;i<6;i++) if(i!=r&&M[i][c]){ int f=M[i][c]; for(int j=c;j<6;j++) M[i][j]=((M[i][j]-f*M[r][j])%3+3)%3; } r++; } return r; } static int applyT(int T[6][6],int v){ int r=0,w=1; for(int i=0;i<6;i++){ int s=0; for(int j=0;j<6;j++) s+=T[i][j]*co[v][j]; r+=(s%3)*w; w*=3; } return r; } static int overlap(int T[6][6]){ int k=0; for(int i=0;i<112;i++) if(inB[applyT(T,Bv[i])]) k++; return k; } static void randT(int T[6][6]){ for(;;){ for(int i=0;i<6;i++) for(int j=0;j<6;j++) T[i][j]=(int)(rnd()%3); if(rank6(T)==6) return; } } static int DLIM=60; struct Stat { long ns[114],ms[114],mu[114]; long kept,ftested,fbad,kbad,lT,lD,lS,oldmax,ncmax,ndirect,disagree,nskip,same,nfew; int rec; }; static int Nn[NV]; static int cz[MAXC],cN[MAXC],cn[2][MAXC],cna[2][MAXC][3],cns[2][MAXC][3]; static int k0[2][MAXC],need[2][MAXC],originCand; static int inS[NV],Sv[112],sIdx[NV]; static void printvec(int z){ for(int i=0;i<6;i++) putchar('0'+co[z][i]); } /* next m-subset of {0,..,n-1} in lexicographic order. The result is 0 at the end. */ static int nextComb(int *idx,int m,int n) { int i=m-1; while(i>=0&&idx[i]==n-m+i) i--; if(i<0) return 0; idx[i]++; for(int j=i+1;jbest) best=h; } while(nv&&nextComb(is,nv,112)); } while(nu&&nextComb(ia,nu,112)); out[f]=best; } } /* Method 2. A position that the punctures make empty must be a class with one to three representations. Only the punctures that are endpoints of these representations change the result. The structural side is A (forms (2,1) and (3,0)), then S (forms (1,2) and (0,3)). */ static int XA[2][MAXC][3],XS[2][MAXC][3]; static int LX[112],LS[112],eX,eS,roomX,roomS,nc,bests,bestu,lTb,lDb,lSb,lTbu; static const int *Bside; static int statsOn,Dbg; static void statusX(const int *U,int nu) { for(int c=0;c=0&&originCand=1){ if(base>bests) bests=(int)base; if(nonant&&statsOn){ int d3=0,d2=0,d1=0; for(int c=0;clDb) lDb=d2; if(d1>lSb) lSb=d1; } } for(int t=0;tbests){ if(Dbg){ printf(" split: A punctures"); for(int q=0;qlDb) lDb=d2; if(d1>lSb) lSb=d1; } } static void evalUnsplitX(const int *U,int sz) { statusX(U,sz); long tot=0; int d3=0; for(int c=0;cbestu) bestu=(int)tot; if(statsOn) lTbu+=d3; } static void smart(int k) { nc=0; originCand=-1; if(k>=26) for(int z=1;z=1&&Nn[z]<=3){ cz[nc]=z; cN[nc]=Nn[z]; int m=0; for(int a=0;a<112;a++){ int s=addt[z][negt[Bv[a]]]; if(inS[s]){ cna[0][nc][m]=a; cns[0][nc][m]=sIdx[s]; m++; } } cn[0][nc]=m; int z2=negt[z]; m=0; for(int a=0;a<112;a++){ int s=addt[z2][negt[Bv[a]]]; if(inS[s]){ cna[1][nc][m]=a; cns[1][nc][m]=sIdx[s]; m++; } } cn[1][nc]=m; nc++; } if(k>=1&&k<=3){ /* the origin has k representations (a,-a) with a in A and S */ originCand=nc; cz[nc]=0; cN[nc]=k; int m=0; for(int a=0;a<112;a++) if(inS[Bv[a]]){ cna[0][nc][m]=a; cns[0][nc][m]=sIdx[negt[Bv[a]]]; m++; } cn[0][nc]=m; cn[1][nc]=0; nc++; } bests=0; bestu=0; lTb=0; lDb=0; lSb=0; lTbu=0; for(int side=0;side<2;side++){ char mx[112],msv[112]; memset(mx,0,sizeof mx); memset(msv,0,sizeof msv); eX=0; eS=0; for(int c=0;cbest){ best=h; for(int t=0;t<3;t++){ ba[t]=ia[t]; bs[t]=is[t]; } } } while(nv&&nextComb(is,nv,112)); } while(nu&&nextComb(ia,nu,112)); printf("form (%d,%d) maximum %d with A punctures",nu,nv,best); for(int t=0;t=1&&Nn[z]<=3) cand++; if(candnfew++; return; } st->ns[k]++; st->kept++; if(verbose>=2){ printf("matrix "); for(int i=0;i<6;i++) for(int j=0;j<6;j++) putchar('0'+T[i][j]); printf("\n"); } memset(isDSg,0,sizeof isDSg); int kd=0; for(int xi=1;xikbad++; for(int z=1;zfbad+=1000000; st->ftested++; if(16-k/2+4*(inB[z]+inS[z])+3*(h/2)!=Nn[z]) st->fbad++; } /* the direct method counts the origin also when it has no representation */ int old=0; for(int z=1;zst->oldmax) st->oldmax=old; (void)dosmart; int low=0; for(int z=0;zndirect++; } else st->nskip++; /* method 2 gives the result and the statistics for the signs */ smart(k); if(nc>st->ncmax) st->ncmax=nc; st->lT+=lTb+lTbu; if(lDb>st->lD) st->lD=lDb; if(lSb>st->lS) st->lS=lSb; if(done){ /* the direct method counts the intact missing positions also */ int n01=((r[0]>r[1])?r[0]:r[1])-old,n23=((r[2]>r[3])?r[2]:r[3])-old; if(bests!=n01||bestu!=n23) st->disagree++; if(verbose>=2) printf("direct %d %d %d %d, method 2 %d %d\n",r[0],r[1],r[2],r[3],n01,n23); if(verbose>=3) printf("method 2 internal %d %d\n",bests,bestu); ts=(r[0]>r[1])?r[0]:r[1]; tu=(r[2]>r[3])?r[2]:r[3]; } else { ts=old+bests; tu=old+bestu; } if(ts>st->ms[k]) st->ms[k]=ts; if(tu>st->mu[k]) st->mu[k]=tu; int m=ts>tu?ts:tu; if(m>st->rec){ st->rec=m; printf("record %d : ",m); if(done) showOne(k,old,r); else { printf("matrix"); for(int i=0;i<6;i++) for(int j=0;j<6;j++) printf(" %d",Tcur[i][j]); printf("\nk %d intact missing %d, split %d, unsplit %d, full enumeration not done (%d positions with at most three representations)\n",k,old,ts,tu,low); } } if(verbose) printf("k %d intact missing %d split %d unsplit %d\n",k,old,ts,tu); } static void report(struct Stat *st) { printf("samples %ld, direct method %ld, disagreements between the two methods %ld, full enumeration not done %ld\n",st->kept,st->ndirect,st->disagree,st->nskip); if(st->nfew) printf("samples with fewer candidates than the limit: %ld\n",st->nfew); if(st->same) printf("maps with S = A: %ld\n",st->same); for(int k=0;k<114;k++) if(st->ns[k]) printf("k %d samples %ld max split %ld max unsplit %ld\n",k,st->ns[k],st->ms[k],st->mu[k]); printf("formula tested %ld mismatches %ld overlap mismatches %ld\n",st->ftested,st->fbad,st->kbad); printf("triples with two signs lost (split and unsplit) %ld\n",st->lT); printf("max doubled doubleton directions for one nonantipodal pair %ld\n",st->lD); printf("max doubled singleton directions for one nonantipodal pair %ld\n",st->lS); printf("max intact missing positions %ld, max candidate count %ld\n",st->oldmax,st->ncmax); printf("record %d\n",st->rec); } static char rows[236][8]; static int cmpstr(const void *a,const void *b){ return strcmp((const char *)a,(const char *)b); } /* next permutation. The result is 0 at the end. */ static int nextPerm(int *p,int n) { int i=n-2; while(i>=0&&p[i]>p[i+1]) i--; if(i<0) return 0; int j=n-1; while(p[j]'2') return 0; for(int i=0;i<6;i++) for(int j=0;j<6;j++) T[i][j]=s[6*i+j]-'0'; return 1; } int main(int argc,char **argv) { if(argc<2) return 2; init(); if(eq(argv[1],"dump236")){ int n=0; for(int L=0;L<3;L++) for(int v=0;v=5){ int L=atoi(argv[2]),part=0,nparts=1; setup(L); const char *type=argv[3]; if(argc>=6&&sscanf(argv[5],"%d/%d",&part,&nparts)!=2) return 2; int bud[16],nbud=0; { const char *p=argv[4]; while(*p){ bud[nbud++]=atoi(p); while(*p&&*p!=',') p++; if(*p) p++; } } if(eq(type,"intact")){ mkmask(-1,-1,-1,0); for(int b=0;b=4){ int L=atoi(argv[2]); setup(L); const char *type=argv[3]; int a=argc>=6?atoi(argv[5]):-1,b=argc>=7?atoi(argv[6]):-1,c=argc>=8?atoi(argv[7]):-1; if(eq(type,"intact")) mkmask(-1,-1,-1,0); else if(eq(type,"dual")) mkdual(); else if(eq(type,"p1w")) mkmask(a,-1,-1,1); else mkmask(a,b,c,0); for(int e=0;e=3){ int L=atoi(argv[2]); setup(L); Lcur=L; crossFlag=1; struct Stat st; memset(&st,0,sizeof st); int T[6][6]; memset(T,0,sizeof T); for(int i=0;i<6;i++) T[i][i]=1; analyze(T,&st,1,0); report(&st); return 0; } if(eq(argv[1],"mono")&&argc>=3){ int L=atoi(argv[2]); setup(L); Lcur=L; struct Stat st; memset(&st,0,sizeof st); int perm[6]; for(int i=0;i<6;i++) perm[i]=i; long n=0; int want=argc>=4?atoi(argv[3]):-1; do { /* the sign of row 0 is fixed, because the cap contains the negative of each of its points */ for(int sgn=0;sgn<32;sgn++){ int T[6][6]; memset(T,0,sizeof T); for(int i=0;i<6;i++) T[i][perm[i]]=(i&&((sgn>>(i-1))&1))?2:1; if(want>=0){ if(overlap(T)==want){ for(int i=0;i<6;i++) for(int j=0;j<6;j++) putchar('0'+T[i][j]); printf("\n"); return 0; } continue; } if(overlap(T)==112){ st.same++; n++; continue; } analyze(T,&st,0,0); n++; } } while(nextPerm(perm,6)); printf("signed permutation matrices tested %ld\n",n); report(&st); { struct Stat s2; memset(&s2,0,sizeof s2); int T[6][6]; memset(T,0,sizeof T); for(int i=0;i<6;i++) T[i][i]=1; DLIM=1000; analyze(T,&s2,0,0); printf("identity map\n"); report(&s2); } return 0; } if(eq(argv[1],"one")&&argc>=4){ int L=atoi(argv[2]); setup(L); struct Stat st; memset(&st,0,sizeof st); int T[6][6]; if(!parseT(argv[3],T)){ printf("the matrix must have 36 digits 0, 1, 2\n"); return 2; } if(rank6(T)!=6){ printf("the matrix is not invertible\n"); return 2; } Dbg=argc>=5; if(argc>=6) DLIM=atoi(argv[5]); analyze(T,&st,argc>=5?3:2,0); report(&st); return 0; } if(eq(argv[1],"pairs")&&argc>=5){ int L=atoi(argv[2]); setup(L); rs=(u64)atoll(argv[3])*2862933555777941757ULL+3037000493ULL; int nsamp=atoi(argv[4]),ndir=argc>=6?atoi(argv[5]):0,verbose=argc>=7?atoi(argv[6]):0; struct Stat st; memset(&st,0,sizeof st); if(argc>=8) DLIM=atoi(argv[7]); if(argc>=9) MinC=atoi(argv[8]); for(int i=0;i=26) analyze(T,&st,verbose,i=6){ int L=atoi(argv[2]); setup(L); rs=(u64)atoll(argv[3])*6364136223846793005ULL+1442695040888963407ULL; int nclimb=atoi(argv[4]),steps=atoi(argv[5]),kstart=argc>=7?atoi(argv[6]):0; struct Stat st; memset(&st,0,sizeof st); for(int i=0;i=k){ memcpy(T,T2,sizeof T2); k=k2; } } if(k>=kstart) analyze(T,&st,1,0); } report(&st); return 0; } return 2; }