back to table · edit · history · where entries came from · files · download
3815 bytes, as of the version from 2026-11-28 22:17 (current). Recorded here, not run.
"""Independently enumerate short primitive geodesics by the legacy Dirichlet method.
Run with SageMath, SnapPy 3.3.2, generate.py, knotinfo-inputs.json and the saved
spectrum-checkpoints.json. Uses independently constructed KnotInfo PD exteriors,
not legacy named knots; high_precision() gives a distinct 212-bit calculation.
This is a numerical cross-check, not a rigorous completeness certificate.
Default execution recomputes every saved knot packet. To resume unchanged results,
explicitly set NUMBERDB_RESUME_LEGACY=1; the saved input hash is then checked.
Output is checkpointed JSON lines, one per knot. Lower-level SnapPy geometry
and the external knot catalogue remain shared assumptions.
"""
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.real_mpfi import RealIntervalField
import snappy,ast,json,time,os
from generate import ROOT,KNOTS,geometric,from_endpoints
R=RealIntervalField(540)
from generate import load_checkpoints
p=load_checkpoints();assert len(p['knots'])>0
skip=set()
if os.environ.get('NUMBERDB_RESUME_LEGACY')=='1':
from generate import INPUT_HASH
saved=json.loads((ROOT/'legacy-checkpoints.json').read_text())
assert saved['input_sha256']==INPUT_HASH and saved['algorithm']=='dirichlet-hp-filtered-v1'
skip={(r['n'],r['k']) for r in saved['knots']}
for row in p['knots']:
n,k=row['n'],row['k']
if (n,k) in skip:continue
start=time.monotonic();print(json.dumps({'event':'starting','n':n,'k':k}),flush=True)
P=geometric(snappy.Link(ast.literal_eval(KNOTS[n,k]['pd_notation'])).exterior())
M=snappy.Manifold(row['triangulation'])
assert M.is_isometric_to(P),('PD braid isometry',n,k)
expected=[from_endpoints(e,R) for e in row['values']]
# Isolate a cutoff strictly between the fourth rank and the next distinct block.
fourth=expected[3];stop=from_endpoints(row['stop']['real'],R)
cutoff=((fourth.upper()+stop.lower())/2)
assert fourth.upper()<QQ(float(cutoff))<stop.lower()
attempts=[]
for attempt in range(6):
try:
spec=P.high_precision().length_spectrum(float(cutoff));break
except RuntimeError as error:
attempts.append(str(error))
print(json.dumps({'event':'dirichlet_retry','n':n,'k':k,'attempt':attempt+1,'reason':str(error)}),flush=True)
if attempt==5:raise
P.randomize();P=geometric(P)
found=[];raw=[];excluded=[]
for g in spec:
x=R(str(g.length.real()))
included=bool(x.upper()<cutoff)
assert abs(x-R(cutoff)).lower()>QQ(1)/10**25,('legacy cutoff too close',n,k)
raw.append({'real':str(g.length.real()),'multiplicity':int(g.multiplicity),'below_cutoff':included})
if included:found.extend([x]*int(g.multiplicity))
else:excluded.append({'real':str(g.length.real()),'multiplicity':int(g.multiplicity)})
found.sort(key=lambda x:x.center())
assert len(found)>=4,('legacy count',n,k,len(found))
# Agreement of a separate algorithm is checked conservatively to 30 decimals.
errors=[abs(found[j]-expected[j]) for j in range(4)]
assert all(e.upper()<QQ(1)/10**30 for e in errors),('legacy spectrum',n,k,[str(e) for e in errors])
expected_count=0
for w in row['witnesses']:
wr=from_endpoints(w['real'],R)
assert wr.upper()<cutoff or wr.lower()>cutoff
if wr.upper()<cutoff:expected_count+=1
assert expected_count>=4
assert len(found)==expected_count,('primitive block multiplicity',n,k,len(found),expected_count)
print(json.dumps({'event':'knot','n':n,'k':k,'pd_braid_isometry':True,'dirichlet_retries':attempts,'legacy_precision_bits':212,'tolerance':'1e-30','cutoff':str(cutoff),'excluded_above_cutoff':excluded,'expected_count_below_cutoff':expected_count,'legacy_spectrum':raw,'witness_count':len(row['witnesses']),'legacy_count':len(found),'rank_errors':[str(e) for e in errors],'seconds':time.monotonic()-start}),flush=True)
print(json.dumps({'event':'complete'}),flush=True)