back to table · edit · history · where entries came from · files · download
2661 bytes, as of the version from 2026-10-29 07:39 (current). Recorded here, not run.
"""Read-only checks for the T603 prose repair.
Run: sage -python repair-checks.py
Keep generate.py, document-before.json and skill-evidence.json beside this file.
The generator is the unchanged website attachment. These checks recompute its
balls and test stored decimal intervals; they are not an independent critique.
"""
import hashlib,json,sys
from decimal import Decimal
from fractions import Fraction
from pathlib import Path
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from sage.rings.complex_arb import ComplexBallField
from sage.env import SAGE_VERSION
from generate import HemisphereDirichlet, logdet
base=Path(__file__).resolve().parent
policy=json.loads((base/'skill-evidence.json').read_text())
doc=json.loads((base/'document-before.json').read_text())
g=HemisphereDirichlet(); R=RealBallField(numberdb.bits(200)); C=ComplexBallField(numberdb.bits(200))
def rational(value):
f=Fraction(value); return QQ(f.numerator)/QQ(f.denominator)
expected=[{'d':d,'convention':c} for d,rows in doc['Numbers'].items() for c in rows]
assert list(g.enumerate())==expected
rows=[]
for params in expected:
stored=doc['Numbers'][params['d']][params['convention']]
v=g.value(params,100)
center=rational(stored); ulp=rational(Decimal(1).scaleb(Decimal(stored).as_tuple().exponent))
assert v.is_finite() and v.accuracy()>=400
assert abs(R(v)-R(center))<R(ulp),params
if params['convention']=='det': assert v>0
rows.append({'params':params,'contained_in_stored_interval':True,'accuracy_bits':int(v.accuracy())})
# Independent low-dimension controls using the displayed spectral identities.
assert logdet(1).overlaps((-2*C(0).zetaderiv(1)).real())
assert logdet(1).exp().overlaps(2*R.pi())
assert logdet(2).overlaps((C(0).zetaderiv(1)-2*C(-1).zetaderiv(1)+QQ(1)/4).real())
assert logdet(3).overlaps((-C(0).zetaderiv(1)+C(-1).zetaderiv(1)-C(-2).zetaderiv(1)-QQ(1)/2).real())
result={'table':'T603','skill_manifest':policy['manifest'],'skill_sha256':{v['source']:v['sha256'] for v in policy['versions']},'generator_sha256':hashlib.sha256((base/'generate.py').read_bytes()).hexdigest(),'stored_entries_checked':len(rows),'minimum_accuracy_bits':min(r['accuracy_bits'] for r in rows),'enumeration_matches_in_order':True,'controls':['d=1 spectral zeta derivative','d=1 determinant 2*pi','displayed d=2 and d=3 formulas'],'scope':'Same-generator interval verification and low-dimension controls; no new values, no independent argument-review verdict.','sage_version':SAGE_VERSION,'python_version':sys.version.split()[0],'rows':rows}
print(json.dumps(result,indent=2))