back to table · edit · history · where entries came from · files · download
4018 bytes, as of the version from 2026-12-01 22:05 (current). Recorded here, not run.
"""Independent exact-rational divisor-series checker; imports no generator.
Run: python check_values.py table-document.json > check-results.json
The bare decimal is an interval of one unit of its last place on either side.
Every stored value must contain the exact bracket [P_M,P_M+(M+2)/2^M],
P_M=sum(d(m)/2^m,m=1..M). Since d(m)<=m, the bound follows from the
geometric derivative sum for sum(m/2^m,m>M). The divisor identity follows
by expanding each 1/(2^n-1) as sum(2^(-n*k),k>=1); nonnegative terms justify
regrouping by m=n*k. See Zudilin arXiv:1601.02688v2 Section 1 equation (1).
The sieve, integer Horner evaluation, arithmetic and rounding comparison are
independent of the builder's denominator loop and Arb implementation.
"""
from fractions import Fraction as F
import json
import sys
def coefficients(M):
d = [0]*(M+1)
for divisor in range(1, M+1):
for multiple in range(divisor, M+1, divisor):
d[multiple] += 1
return d
def polynomial(d):
# P_M has denominator 2^M. Append descending binary place values.
numerator = 0
for count in d[1:]:
numerator = 2*numerator + count
return F(numerator, 2**(len(d)-1))
def bracket(decimal_digits=130):
M = 1
while F(M+2, 2**M) > F(1,10**decimal_digits):
M += 1
lower = polynomial(coefficients(M))
return lower, lower+F(M+2,2**M), M
def bounds(text):
# Decimal is the intentionally chosen storage form, not an exact value.
assert isinstance(text,str) and '.' in text and 'e' not in text.lower()
assert text.replace('.','',1).isdigit()
p = len(text.split('.')[1]); c=F(text); u=F(1,10**p)
return c-u,c+u,u
def contains_valid_claim(text, lower, upper):
a,b,u=bounds(text)
return bool(0<b-a<=F(2,10**99) and 1<a<b<2 and a<=lower<=upper<=b)
def check(document):
failures=[]; controls={}
d=coefficients(6)
controls['divisor_coefficients']=d[1:]==[1,2,2,3,2,4]
controls['finite_polynomial']=polynomial(d)==F(25,16)
controls['geometric_tail_identity']=2-polynomial(list(range(7)))==F(8,64)
lower,upper,M=bracket()
assert F(0)<upper-lower<=F(1,10**130)
known='1.606695152415291763'
a,b,_=bounds(known)
controls['published_prefix']=a<=lower<=upper<=b
numbers=document['Numbers']
text=numbers[0]['number'] if isinstance(numbers[0],dict) else numbers[0]
if document.get('Parameters') not in ({},None,''): failures.append('constant has parameters')
if len(numbers)!=1: failures.append('constant requires exactly one value')
if isinstance(numbers[0],dict) and numbers[0].get('id'):failures.append('singleton has an id')
good=contains_valid_claim(text,lower,upper)
if not good:failures.append('stored interval does not contain the independent bracket')
a,b,u=bounds(text); midpoint=(a+b)/2
def wrong_contains(shift):
return a+shift<=lower<=upper<=b+shift
negatives={'shift_1e-90_rejected':not wrong_contains(F(1,10**90)),
'omit_first_term_rejected':not (a<=lower-1<=upper-1<=b),
'wide_interval_rejected':not contains_valid_claim('1.6',lower,upper)}
return {'checked_entries':1,'total_entries':1,'failures':failures,
'known_answer_control':all(controls.values()),
'negative_control_rejected':all(negatives.values()),
'controls':controls,'negative_controls':negatives,
'method':'Exact divisor sieve, integer Horner polynomial, d(m)<=m tail',
'terms':M,'independent_lower':str(lower),'independent_upper':str(upper),
'independent_width':str(upper-lower),'stored_value':text,
'stored_lower':str(a),'stored_upper':str(b),'stored_ulp':str(u),
'bracket_contained':good,'midpoint_offset_lower_in_ulps':str((lower-midpoint)/u)}
if __name__=='__main__':
d=json.load(open(sys.argv[1]));r=check(d);print(json.dumps(r,indent=2))
if r['failures'] or not r['known_answer_control'] or not r['negative_control_rejected']:
raise SystemExit(1)