back to table · edit · history · where entries came from · files · download
3287 bytes, as of the version from 2026-10-25 05:25 (current). Recorded here, not run.
"""Independent T473 repair checks. Run: sage -python repair_checks.py.
Requires generate.py, checks.py, check.py, T473-before.json and
T473-proposed.json alongside this file. A draft-readable
NumberDB API key is read from stdin. Writes nothing to the website. Checks exact
source-interval transcriptions and algebra, not bootstrap optimisation bounds.
"""
import sys, json, re, itertools, platform
from fractions import Fraction
import numberdb.sage as numberdb
from sage.rings.rational_field import QQ
from sage.version import version as sage_version
from generate import IsingScalingDimensions
from checks import run, normalize_numbers
numberdb.configure(api_key=sys.stdin.read().strip(),base_url='https://numberdb.org')
doc=numberdb.table('T473')
source={'sigma':'0.518148806(24)','epsilon':'1.41262528(29)',
'epsilon-prime':'3.82951(61)','sigma-prime':'5.262(89)'}
def q(s):
x=Fraction(s)
return QQ(x.numerator)/QQ(x.denominator)
intervals={}
for name,spelling in source.items():
m=re.fullmatch(r'(\d+\.\d+)\((\d+)\)',spelling)
c=q(m[1]); radius=QQ(int(m[2]))/QQ(10**len(m[1].split('.')[1]))
expected=(c-radius,c+radius)
center,error=map(q,doc['Numbers'][name]['number'].split(' +/- '))
assert (center-error,center+error)==expected,name
assert radius>0 and expected[0]>=QQ(1)/QQ(2)
intervals[name]=expected
assert doc['Numbers']['T']['number']=='3'
assert intervals['sigma'][1]<intervals['epsilon'][0]<3
assert intervals['epsilon-prime'][0]>3 and intervals['sigma-prime'][0]>3
# Check all eight exact corners of the source box; these are algebraic checks,
# not a claim that the separate bootstrap intervals form a joint allowed region.
one,two,three=map(QQ,(1,2,3))
corner_count=0
for s,e,p in itertools.product(intervals['sigma'],intervals['epsilon'],intervals['epsilon-prime']):
nu=one/(three-e); eta=two*s-one; omega=p-three
beta=s/(three-e); gamma=(three-two*s)/(three-e)
delta=(three-s)/s; alpha=two-three/(three-e)
residuals=[alpha+two*beta+gamma-two,gamma-beta*(delta-one),
gamma-nu*(two-eta),two-alpha-three*nu,alpha+beta*(one+delta)-two]
assert all(x==0 for x in residuals)
assert omega>0
corner_count+=1
# Formatting retains all seven TeX identities verbatim, in the same order.
from pathlib import Path
base=Path(__file__).parent
before=json.loads((base/'T473-before.json').read_text())
after=json.loads((base/'T473-proposed.json').read_text())
assert before['Formulas']['dimensions-exponents'][1:-2].split(r',\quad')==re.findall(r'\$(.*?)\$',after['Formulas']['dimensions-exponents'])
assert before['Numbers']==after['Numbers']==doc['Numbers']
assert before['Parameters']==after['Parameters']==doc['Parameters']
report=IsingScalingDimensions().verify(sample=None)
assert report.ok,str(report)
retained_checks=run(normalize_numbers(doc['Numbers']),numberdb.table('T472'))
print(json.dumps({'ok':True,'python':platform.python_version(),'sage':sage_version,
'numberdb':numberdb.__version__,'four_exact_source_transcriptions':{k:list(map(str,v)) for k,v in intervals.items()},
'stress_tensor_exact':True,'scaling_identities_at_each_corner':5,'box_corners':corner_count,'tex_identities_unchanged':7,
'generator_verify':str(report),'retained_build_checks':retained_checks},indent=2))