back to table · edit · history · where entries came from · files · download
1538 bytes, as of the version from 2026-12-01 14:15 (current). Recorded here, not run.
import sys,json,time
from pathlib import Path
from backhouse_math import enclose_between,QQ,RealBallField
from backhouse_math import root_certificate,circle_certificate
from sage.env import SAGE_VERSION
import numberdb.sage as numberdb
start=time.monotonic()
print('Root certificate starts',flush=True)
checkpoint=Path(__file__).with_name('root-certificate.json')
if checkpoint.exists():
root=json.loads(checkpoint.read_text()); R=RealBallField(root['bits'])
B=enclose_between(R,QQ(root['B'][0]),QQ(root['B'][1]))
else: B,root=root_certificate()
print('ROOT_JSON '+json.dumps(root),flush=True)
print('Root certificate complete',str(B),flush=True)
print('Contour certificate starts',flush=True)
contour=circle_certificate([1]+root['primes'],root['N'])
assert contour['zero_count']==1
print('Contour complete',len(contour['arcs']),'arcs; count',contour['zero_count'],flush=True)
controls={}
for name,coeff,expected in [('linear',[1,2],1),('constant',[1],0),('two_roots',[1,0,4],2),('outside_root',[1,1],0)]:
c=circle_certificate(coeff,0,bits=128,with_tail=False)
assert c['zero_count']==expected
controls[name]={'count':c['zero_count'],'expected':expected,'arcs':len(c['arcs'])}
controls['wrong_count_rejected']=contour['zero_count']!=2
assert controls['wrong_count_rejected']
result={'root':root,'contour':contour,'controls':controls,
'versions':{'sage':SAGE_VERSION,'numberdb':numberdb.__version__,'python':sys.version},
'elapsed_seconds':time.monotonic()-start}
print('ARTIFACT_JSON '+json.dumps(result),flush=True)