back to table · edit · history · where entries came from · files · download
4047 bytes, as of the version from 2026-10-30 04:07. Recorded here, not run.
"""Check every stored T617 pressure interval and family identity after readback.
Run with SageMath: sage -python readback_checks.py
Requires numerical-evidence.json, independent-evidence.json, skill-manifest.json,
generate.py and solver.py beside this script. Use NUMBERDB_API_KEY to read the
draft, or pipe it with NUMBERDB_KEY_FROM_STDIN=1 in the campaign wrapper.
"""
import os,sys,json
from pathlib import Path
from decimal import Decimal,localcontext
import numberdb.sage as numberdb
from sage.rings.real_arb import RealBallField
from sage.rings.rational_field import QQ
from generate import INDICES
def textvalue(item):
return item['number'] if isinstance(item,dict) else item
def interval(s,B):
# Pressure rows are decimal intervals; companion C_0=1 is exact.
if '.' not in s and 'e' not in s.lower():
q=QQ(s)
exact=Decimal(int(q.numerator()))/Decimal(int(q.denominator()))
return B(q),exact,exact
d=Decimal(s);ulp=Decimal(10)**d.as_tuple().exponent
lo=d-ulp;hi=d+ulp
return B(str(d)).add_error(B(str(ulp))),lo,hi
def main():
if os.environ.get('NUMBERDB_KEY_FROM_STDIN')=='1':
token=sys.stdin.read().strip()
if '=' in token and token.split('=',1)[0].replace('_','').isalnum():
token=token.split('=',1)[1].strip().strip('\"\'')
os.environ['NUMBERDB_API_KEY']=token
p=Path(__file__).parent
primary=json.loads((p/'numerical-evidence.json').read_text())['values']
independent=json.loads((p/'independent-evidence.json').read_text())
manifest=json.loads((p/'skill-manifest.json').read_text())
assert manifest['status']=='ready' and len(set(v['sha256'] for v in manifest['versions']))==1
d=numberdb.table('T617');r=numberdb.table('T613');m=numberdb.table('T614');c=numberdb.table('T615')
assert list(d['Numbers'])==list(INDICES)
assert d['Title']=='Central pressure constants of Lane–Emden polytropes'
assert d['Display properties']['number-header']=='$W_n$'
report={'table':'T617','skill_manifest':'agents/runs/20261030T035316Z-build-skills/manifest.json','rows':{}}
B=RealBallField(800)
with localcontext() as ctx:
ctx.prec=260
for n in INDICES:
s=textvalue(d['Numbers'][n]);W,lo,hi=interval(s,B)
assert W.is_finite() and B(W.rad())/abs(W)<B('1e-98')
count=len(Decimal(s).as_tuple().digits);assert count>=100
for key in ('low','high'):
assert lo<Decimal(primary[n][key])<hi,(n,key)
if n in ('0','1'):
target=B(3)/(8*B.pi()) if n=='0' else B.pi()/8
assert target.is_finite() and B(target.rad())<B('1e-220')
assert B(str(lo))<target and target<B(str(hi))
X,xlo,xhi=interval(textvalue(r['Numbers'][n]),B)
M,mlo,mhi=interval(textvalue(m['Numbers'][n]),B)
C,_,_=interval(textvalue(c['Numbers'][n]),B)
assert xlo<Decimal(primary[n]['xi'])<xhi
assert mlo<Decimal(primary[n]['mu'])<mhi
NN=B(QQ(n))
surface=X**4/(4*B.pi()*(NN+1)*M**2)
concentration=9*C**2/(4*B.pi()*(NN+1)*X**2)
for target in (surface,concentration):
assert target.is_finite() and B(target.rad())/abs(target)<B('1e-95'),(n,'uninformative target',str(target))
assert W.overlaps(target),(n,'family identity')
ir=independent[n];xi=B(ir['radius']);J=B(ir['pressure_integral'])
virial=xi**3/(4*B.pi()*(5-NN)*J)
assert abs((W-virial)/W)<B('1e-40'),(n,'virial')
independently=Decimal(ir['pressure'])
error=abs((independently-Decimal(s))/Decimal(s));assert error<Decimal('1e-40')
assert not lo<Decimal(s)+100*(hi-lo)<hi
report['rows'][n]={'stored_interval_pass':True,'significant_digits':count,'family_identities_overlap':True,'independent_virial_relative_error':str(error),'displaced_interval_rejected':True}
print('DATA '+json.dumps(report),flush=True)
if __name__=='__main__':main()