postfill_cached.py

back to table · edit · history · where entries came from · files · download

2116 bytes, as of the version from 2026-11-18 04:29 (current). Recorded here, not run.

"""Verify stored T743 against preserved actual generator outputs.

The original 73-entry primary computation is checkpointed and hash-bound.
No quadrature is rerun here. This is an explicit cache replay through the
unchanged generator value/verify machinery, not a fresh numerical computation.
All stored intervals also have the separate original-polynomial check.
"""
import sys,json,hashlib
from pathlib import Path
import numberdb.sage as numberdb
from sage.rings.real_mpfi import RealIntervalField
import generate
from independent_check import compare
from mpmath import mp
W=Path(__file__).parent;c=numberdb.Client(api_key=sys.stdin.read().strip())
evidence=json.loads((W/'numerical-evidence.json').read_text())
for name in ['generate.py','compute-checkpoint.json']:
    assert hashlib.sha256((W/name).read_bytes()).hexdigest()==evidence['hashes'][name]
saved=json.loads((W/'compute-checkpoint.json').read_text())
intervals={r['record']['params']['k']:r['agreement_interval'] for r in saved}
assert list(intervals)==[p['k'] for p in generate.Boyd35B().enumerate()]
F=RealIntervalField(700)
generate.computed=lambda n,sign,digits:F(intervals[generate.key(n,sign)])
doc=numberdb.table('T743',client=c)
entries=[{'params':{'k':str(k)},**(v if isinstance(v,dict) else {'number':v})} for k,v in doc['Numbers'].items()]
reference=json.loads((W/'independent-results.json').read_text());bykey={r['k']:r for r in reference['rows']}
with mp.workdps(155):
    assert len(entries)==73
    assert all(compare(r,mp.mpf(bykey[r['params']['k']]['value']))[0] for r in entries)
report=generate.Boyd35B().verify(sample=None,client=c)
print('VERIFY '+str(report),flush=True)
fields={k:getattr(report,k) for k in report.__slots__}
print('VERIFY_FIELDS '+json.dumps(fields,default=str),flush=True)
print('VERIFY_MODE '+json.dumps({'mode':'preserved primary interval cache replay','generator_and_checkpoint_hashes_checked':True,'fresh_recomputation_verdict':'not captured: exec session returned 143 and its builder child later exited without final output; not claimed as passed'}),flush=True)
assert report.ok and report.checked==73