back to table · edit · history · where entries came from · files · download
4126 bytes, as of the version from 2026-10-28 04:58 (current). Recorded here, not run.
"""T571 repair checks: precision metadata, displayed program, and dimensions.
Run with SageMath and numberdb installed:
sage -python repair-check.py document.json repair-skill-manifest.json
Export document.json from GET https://numberdb.org/api/table?id=T571.
For a draft, authenticate the API read with an authorized account.
This script only reads files and prints JSON. It neither edits nor offers a table.
The displayed gamma-product program is checked against all stored intervals.
Four elementary disk/sphere/ball controls are independent of that program.
No generator or value is changed by this repair.
"""
import json,sys,hashlib
from pathlib import Path
from decimal import Decimal
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from sage.rings.real_mpfi import RealIntervalField
from sage.version import version as sage_version
here=Path(__file__).resolve().parent
path=Path(sys.argv[1]) if len(sys.argv)>1 else here/'document-before.json'
manifest_path=Path(sys.argv[2]) if len(sys.argv)>2 else here/'skill-manifest.json'
document=json.loads(path.read_text()); manifest=json.loads(manifest_path.read_text())
namespace={};exec(document['Programs']['program-sage']['code'],namespace)
function=namespace['hs_volume']; R=RealBallField(640); I=RealIntervalField(700)
def decimal_exact(text):
number=Decimal(text); sign,digits,exponent=number.as_tuple()
mantissa=int(''.join(map(str,digits))) * (-1 if sign else 1)
return QQ(mantissa)*QQ(10)**exponent, QQ(10)**exponent,len(digits)
def enclosed(ball,text):
assert ball.is_finite() and ball>0
center,ulp,digits=decimal_exact(text)
interval=I(ball)
lower=interval.lower().exact_rational();upper=interval.upper().exact_rational()
assert center-ulp<=lower<=upper<=center+ulp
error=max(abs(lower-center),abs(upper-center))/ulp
return {'digits':digits,'accuracy_bits':int(ball.accuracy()),'max_error_ulps':str(R(error))}
rows=[];identities=[]
for field,sizes in document['Numbers'].items():
beta={'real':1,'complex':2}[field]
for n,ranks in sizes.items():
N=int(n)
for rank,text in ranks.items():
r=int(rank);identities.append((field,N,r))
dimension=r-1+QQ(beta*r*(2*N-r-1))/2
support=beta*r*(N-r)
supported_positive_matrices=r+QQ(beta*r*(r-1))/2-1
assert dimension==support+supported_positive_matrices
ball=function(field,N,r,digits=160)
result=enclosed(ball,text); assert result['digits']==100
rows.append({'field':field,'N':N,'rank':r,**result})
expected=[(field,N,r) for field in ('real','complex') for N in range(2,17) for r in range(1,N+1)]
assert identities==expected
radius=R(1)/R(2).sqrt()
controls={('real',1):2*R.pi()*radius,('real',2):R.pi()*radius**2,
('complex',1):4*R.pi()*radius**2,('complex',2):R(4)/3*R.pi()*radius**3}
control_results=[]
for (field,r),ball in controls.items():
result=enclosed(ball,document['Numbers'][field]['2'][str(r)])
control_results.append({'field':field,'N':2,'rank':r,**result})
assert document['Data properties']['digits']=='100'
result={'table':'T571','stage':'repair','source_document_sha256':hashlib.sha256(path.read_bytes()).hexdigest(),
'skill_manifest':'agents/runs/20261028T045358Z-repair-skills/manifest.json','skill_versions':manifest['versions'],
'sage_version':sage_version,'precision_claim':'100 significant digits, one unit uncertainty in the last place',
'arguments':'Exact integer field index, size and rank. Rational arguments are enclosed by Arb; uncertainty propagates through gamma and power operations.',
'program_checks':len(rows),'dimension_checks':len(rows),'independent_elementary_controls':control_results,
'minimum_program_accuracy_bits':min(x['accuracy_bits'] for x in rows),'results':rows,
'limitations':'The displayed program uses the same general formula as the generator. Four geometric controls are independently evaluated. This is a repair check, not a replacement independent argument critique.'}
print(json.dumps(result,indent=2))