back to table · edit · history · where entries came from · files · download
1285 bytes, as of the version from 2026-11-10 00:44 (current). Recorded here, not run.
"""Exact interval identity checks on downloaded T700 values, without recomputation.
python3 stored_relations.py stored-document.json
"""
import sys,json
from decimal import Decimal
from fractions import Fraction
from pathlib import Path
d=json.loads(Path(sys.argv[1]).read_text())
assert list(d['Parameters'])==['Delta','N','r','s']
intervals={}
def walk(node,keys=()):
if len(keys)==4:
yield keys, node['number'] if isinstance(node,dict) else node
else:
for key,value in node.items():yield from walk(value,keys+(int(key),))
for key,text in walk(d['Numbers']):
t=Decimal(text.rstrip('?'));v=Fraction(t)
u=Fraction(10)**t.as_tuple().exponent
intervals[key]=(v-u,v+u)
count=0;distinct=0
for (delta,N,r,s),(low,high) in intervals.items():
b=delta%2
c=(r,(b*r-s)%N)
inv=((-c[0])%N,(-c[1])%N)
rep=min(c,inv);sign=1 if c==rep else -1
partner=(delta,N,*rep)
pl,ph=intervals[partner]
if sign<0:pl,ph=-ph,-pl
# D(u)+D(conjugate multiplicative argument)=0.
assert low+pl<=0<=high+ph,((delta,N,r,s),partner)
count+=1
distinct+=partner!=(delta,N,r,s)
print(json.dumps({'table':'T700','checks_from_stored_intervals':count,'checks_between_distinct_stored_rows':distinct,'arithmetic':'exact Fraction endpoints derived from the last-place convention','result':'pass'},indent=2))