back to table · edit · history · where entries came from · files · download
2996 bytes, as of the version from 2026-11-20 03:35 (current). Recorded here, not run.
"""Standard-library exact check of the frozen T770 input catalogue.
Run python3 input_check.py beside points.txt and the pinned full source files.
"""
from pathlib import Path
from fractions import Fraction as Q
import json,hashlib
w=Path(__file__).parent
expected={'allgens.txt':'d4200efe89ce8cb7874040711878fa11f04468e3181e9b8e43fd0f84ae0f1175','allcurves.txt':'259f3846329395b371e8079c77a6f1097adaebc98a054974573e241416efa968','allcurves-next.txt':'8cb6f95c0a42e8ae575350e761b80870a64d3b9bb3bab698341b03b4b0cac1db','points.txt':'049273399057ba95739695c3a848bc2bc1791bee35a4e5d90c8048e11471fc21'}
for n,h in expected.items():assert hashlib.sha256((w/n).read_bytes()).hexdigest()==h
source=(w/'allgens.txt').read_text().splitlines();selected=[]
for l in source:
a=l.split();N=int(a[0]);r=int(a[4])
if a[2]=='1' and ((r==1 and N<=175) or (r==2 and N<=2000) or (r>=3 and N<=10000)):selected.append(l)
assert '\n'.join(selected)+'\n'==(w/'points.txt').read_text()
companion={tuple(l.split()[:3]):l.split() for l in (w/'allcurves.txt').read_text().splitlines()}
assert not any(l.startswith('10000 ') for l in (w/'allcurves-next.txt').read_text().splitlines())
exception=[l.split() for l in source if l.startswith('990 h 3 ')];assert len(exception)==1 and exception[0][4]=='1'
counts={p:0 for p in [5,7,11,13]};ranks={1:0,2:0,3:0};anomalous=0;entries=0;point_count=0;catalogue=[]
for l in selected:
a=l.split();N=int(a[0]);r=int(a[4]);co=json.loads(a[3]);c=companion[tuple(a[:3])];assert c[3]==a[3] and c[4]==a[4]
a1,a2,a3,a4,a6=co
b2=a1*a1+4*a2;b4=2*a4+a1*a3;b6=a3*a3+4*a6;b8=a1*a1*a6+4*a2*a6-a1*a3*a4+a2*a3*a3-a4*a4
c4=b2*b2-24*b4;c6=-b2**3+36*b2*b4-216*b6;disc=-b2*b2*b8-8*b4**3-27*b6*b6+9*b2*b4*b6
assert c4**3-c6*c6==1728*disc
points=[]
for q in a[6:]:
X,Y,Z=map(int,q.strip('[]').split(':'));x,y=Q(X,Z),Q(Y,Z)
assert y*y+a1*x*y+a3*y==x**3+a2*x*x+a4*x+a6
points.append([str(x),str(y)]);point_count+=1
primes=[]
for p in counts:
card=1+sum((y*y+a1*x*y+a3*y-x**3-a2*x*x-a4*x-a6)%p==0 for x in range(p) for y in range(p))
ap=p+1-card
if disc%p and ap%p:
counts[p]+=1;entries+=r*(r+1)//2;anomalous+=int(ap%p==1);primes.append({'p':p,'ap':ap,'cardinality':card})
ranks[r]+=1
catalogue.append({'label':a[0]+a[1]+a[2],'N':N,'c4':c4,'c6':c6,'ainvs':co,'rank':r,'points':points[:r],'torsion_points':points[r:],'eligible':primes})
assert len({(r['N'],r['c4'],r['c6']) for r in catalogue})==158
assert counts=={5:134,7:137,11:128,13:142} and entries==1249 and anomalous==47 and ranks=={1:60,2:97,3:1}
out={'curve_count':len(selected),'point_equations_checked':point_count,'rank_counts':ranks,'curve_prime_counts':counts,'entries':entries,'anomalous':anomalous,'source_hashes':expected,'companion_models_and_ranks_match':True,'optimality_exception_outside_selected_envelope':True,'conductor_10000_endpoint_empty':True,'catalogue':catalogue}
(w/'input-evidence.json').write_text(json.dumps(out,indent=2));print(json.dumps({k:v for k,v in out.items() if k!='catalogue'},indent=2))