stored_identity_check.py

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

3399 bytes, as of the version from 2026-11-18 14:47 (current). Recorded here, not run.

"""Recheck mathematical comparisons on the exact stored entry strings.
Reuse completed independent computations only after confirming identical
entry identities and strings, then rerun the comparisons and controls.
The even enclosures are certified central-xi series; mpmath and resolvent
values supply numerical agreement checks with the stated limitations.
"""
import os,pathlib,json,re
from decimal import Decimal
from fractions import Fraction as F
from math import comb
w=pathlib.Path(os.environ['TMPDIR'])
stored=json.loads((w/'stored-values.json').read_text());offline=json.loads((w/'computed-values.json').read_text())
assert [(str(r['s']),r['written']) for r in stored]==[(str(r['s']),r['written']) for r in offline]
rows={str(r['s']):r['written'] for r in stored}
def limits(text):
 if '/' in text or ('.' not in text and 'e' not in text.lower()):return F(text),F(text)
 d=Decimal(text);v=F(d);ulp=F(10)**d.as_tuple().exponent;return v-ulp,v+ulp
checks=[];failures=[]
def record(name,s,ok):
 x={'method':name,'s':s,'passed':bool(ok)};checks.append(x)
 if not ok:failures.append(x)
def contains_ball(written,text):
 text=text.strip().strip('[]');center,radius=text.split('+/-');c=F(center.strip());r=F(radius.strip());lo,hi=limits(written)
 return 0<r<abs(c)/10**105 and lo<=c-r and c+r<=hi
E=[1]
for n in range(1,21):E.append(-sum(comb(n,k)*E[k] for k in range(n) if (n-k)%2==0))
for s in [0]+list(range(-2,-21,-2)):
 n=-s//2;v=F((-1)**n*(8-E[2*n]),2**(2*n+3));record('exact Euler recurrence',s,limits(rows[str(s)])==(v,v))
reference=json.loads((w/'independent-results.json').read_text());assert not reference['failures']
for c in reference['checks']:
 s=str(c['s'])
 if c['method']=='Arb central-xi log series':record('stored contains independent xi ball',s,contains_ball(rows[s],c['enclosure']))
 if c['method']=='mpmath secondzeta independent implementation':
  v=F(c['value']);lo,hi=limits(rows[s]);record('stored interval versus independent mpmath value',s,lo<=v<=hi)
odd=json.loads((w/'odd-resolvent-results.json').read_text());assert not odd['failures']
for c in odd['checks']:
 v=F(c['value']);lo,hi=limits(rows[str(c['s'])]);record('stored interval versus independent odd resolvent integral',c['s'],lo<=v<=hi)
first=next(c for c in reference['checks'] if c['method']=='Arb central-xi log series' and c['s']==2)
# Explicit deliberately wrong factors, sign and a vacuous ball.
text=first['enclosure'].strip().strip('[]');center,radius=text.split('+/-');c=F(center.strip());r=F(radius.strip());lo,hi=limits(rows['2'])
negative=all(not (lo<=v-r and v+r<=hi) for v in [2*c,-c,4*c]) and not contains_ball(rows['2'],'[1 +/- 1000]')
known=(limits(rows['0'])==(F(7,8),F(7,8)) and limits(rows['-2'])==(F(-9,32),F(-9,32)) and F(480,289)!=2)
report={'table':'T752','total_entries':60,'checked_entries':len(set(str(c['s']) for c in checks)),'comparisons':len(checks),'failures':failures,'known_answer_control':known,'negative_control_rejected':negative,'stored_strings_equal_computed_checkpoint':True,'checks':checks,'reuse':'Independent reference computations are reused only for byte-identical stored entry strings; mathematical comparisons and controls rerun here.'}
(w/'stored-identity-results.json').write_text(json.dumps(report,indent=2)+'\n')
print(json.dumps({k:v for k,v in report.items() if k!='checks'}))
assert report['checked_entries']==60 and not failures and known and negative