back to table · edit · history · where entries came from · files · download
10417 bytes, as of the version from 2026-12-02 04:01 (current). Recorded here, not run.
"""Builder checks for either-direction wrapping; this is not an independent critique.
Requires SageMath 10.9 and numberdb. Run read-only:
sage -python build_check.py --entries entries.json
sage -python build_check.py --table T861
Supply NUMBERDB_API_KEY for private reads, or pipe it with
NUMBERDB_KEY_FROM_STDIN=1. JSON results go to stdout.
Independent route: R_e=X+P_(1,0)+P_(0,1)+D with D=2*sum over positive primitive
(a,b), while production uses 1-X. P is evaluated via the original
five residue sums in Pruessner--Moloney (1)--(2); X via explicitly bounded
2D partition sums in Ziff--Lorenz--Kleban (9). Native Arb eta is independent
of production's eta product. A second X evaluation uses their reciprocal
product (10), native Arb theta/eta. No production helper is imported.
D is summed through a,b<=32, discarding coprimality only in its exterior
majorant. With c=2*pi/3, A=a^2/r+b^2*r>=2, and
pref=sqrt(2/(3*r))/eta(i*r)^2, the absolute compact Gaussian coefficients
sum to 8, and sum_(k>=1)exp(-c*A*k^2)<=exp(-c*A)/(1-exp(-6*c)).
Consequently D outside the box is bounded by 16*pref/(1-exp(-6*c)) times
the exterior of the positive Gaussian product. This bound is added to D.
The same analytic CFT input is shared; no physical limit is proved here.
"""
import argparse
from fractions import Fraction
from functools import lru_cache
from math import gcd
import json,os,re,sys
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
BITS=640
F=RealBallField(BITS);C=ComplexBallField(BITS)
def rational(x):
f=Fraction(str(x)); return QQ(f.numerator)/f.denominator
@lru_cache(maxsize=50000)
def eta(r):
e=C(0,F(r)).modular_eta()
assert e.real().is_finite() and e.imag().is_finite() and e.imag().contains_zero()
assert e.real().lower()>0 and e.real().accuracy()>BITS-30
return e.real()
def theta(t):
v=C(0).jacobi_theta(C(0,F(t)))[2]
assert v.real().is_finite() and v.imag().is_finite() and v.imag().contains_zero()
return v.real()
@lru_cache(maxsize=50000)
def residue_probability(r,a,b):
r=QQ(r); A=QQ(a*a)/r+b*b*r
c=F.pi()*F(QQ(2)/3)*F(A)
k=0
target=F(2)**(-BITS+40)
while True:
tail=4*(-c*(k+1)**2).exp()/(1-(-c*(2*k+3)).exp())
if tail.upper()<target.lower(): break
k+=1
gaussians={n:(-c*n*n).exp() for n in range(-k,k+1)}
# The five sums in (1); do not use the compact theta coefficients.
s0=sum((v for n,v in gaussians.items() if n%3==0),F(0))
s1=sum((v for n,v in gaussians.items() if n%3==1),F(0))
s2=sum((v for n,v in gaussians.items() if n%3==2),F(0))
seven=sum((v for n,v in gaussians.items() if n%2==0),F(0))
sodd=sum((v for n,v in gaussians.items() if n%2==1),F(0))
raw=(s0-(s1+s2)/2-seven+sodd).add_error(tail)
return (F(QQ(2)/(3*r))).sqrt()*raw/eta(r)**2
def gaussian_box(h,r):
alpha=F.pi()*F(h/r); beta=F.pi()*F(h*r)
target=F(2)**(-BITS+48)
def extent(c):
n=0
while True:
tail=2*(-c*(n+1)**2).exp()/(1-(-c*(2*n+3)).exp())
if tail.upper()<target.lower(): return n,tail
n+=1
nx,tx=extent(alpha); ny,ty=extent(beta)
# Direct two-dimensional sum, rather than production's theta product.
partial=sum(((-alpha*m*m-beta*n*n).exp()
for m in range(-nx,nx+1) for n in range(-ny,ny+1)),F(0))
sx=sum(((-alpha*m*m).exp() for m in range(-nx,nx+1)),F(0))
sy=sum(((-beta*n*n).exp() for n in range(-ny,ny+1)),F(0))
exterior=tx*(sy+ty)+sx*ty
return partial.add_error(exterior),{'x_extent':nx,'y_extent':ny,'exterior_bound':str(exterior.upper())}
@lru_cache(maxsize=256)
def partition_cross(r):
r=QQ(r); sums=[]; details=[]
for h in [QQ(8)/3,QQ(2)/3]:
s,d=gaussian_box(h,r); sums.append(F(h/r).sqrt()*s/eta(r)**2); details.append(d)
return (sums[0]-sums[1])/2,details
def reciprocal_product(r):
r=QQ(r)
return (F(QQ(3)/2).sqrt()/4)*(theta(QQ(3)*r/8)*theta(QQ(3)/(8*r))
-2*theta(QQ(3)*r/2)*theta(QQ(3)/(2*r)))/(eta(r)*eta(1/r))
def decimal_interval(text):
match=re.fullmatch(r'([+-]?\d+)(?:\.(\d+))?(?:[eE]([+-]?\d+))?',str(text))
if not match: raise ValueError('Expected an ordinary stored decimal')
center=Fraction(str(text)); decimals=match.group(2)
exponent=int(match.group(3) or '0')
if decimals is None and match.group(3) is None:
return rational(center),rational(center),QQ(0)
unit=Fraction(10)**(exponent-len(decimals or ''))
return rational(center-unit),rational(center+unit),rational(unit)
def narrow(v,digits=120):
return bool(v.is_finite() and v.lower()>0 and
(v.rad_as_ball()/abs(v)).upper() < (F(10)**(-digits)).lower())
def same(v,w):
return bool(narrow(v) and narrow(w) and v.overlaps(w))
def diagonal_tail_bound(r,M):
# Bound D=2*sum_{a,b>=1,gcd=1}P outside a,b<=M; discard coprimality.
r=QQ(r); c=2*F.pi()/3
alpha=c/F(r); beta=c*F(r)
def positive_bound(t): return (-t).exp()/(1-(-3*t).exp())
def tail_bound(t): return (-t*(M+1)**2).exp()/(1-(-t*(2*M+3)).exp())
pref=F(QQ(2)/(3*r)).sqrt()/eta(r)**2
return 16*pref/(1-(-6*c).exp())*(tail_bound(alpha)*positive_bound(beta)+positive_bound(alpha)*tail_bound(beta))
def expected_selection():
s=sorted({Fraction(u,v) for v in range(1,7) for u in range(v,7)})
return [str(r) for r in s]
def event_sum(r):
r=QQ(r); M=32
d=2*sum((residue_probability(r,a,b) for a in range(1,M+1)
for b in range(1,M+1) if gcd(a,b)==1),F(0))
tail=diagonal_tail_bound(r,M);d=d.add_error(tail)
x,details=partition_cross(r); px=residue_probability(r,1,0); py=residue_probability(r,0,1)
re=x+px+py+d
partition=2*x+px+py+d-1
return re,{'D':d,'X':x,'Px':px,'Py':py,'partition':partition,
'tail':tail,'box':details,'M':M}
def matches(text,v):
if not narrow(v,130) or v.upper()>=1:return False
lo,hi,ulp=decimal_interval(text)
return bool(v.lower()>=lo and v.upper()<=hi)
def records_of(d):
if isinstance(d['Numbers'],list):return d['Numbers']
return [{'params':{'r':str(k)},**(v if isinstance(v,dict) else {'number':v})}
for k,v in d['Numbers'].items()]
def main():
parser=argparse.ArgumentParser(description=__doc__)
parser.add_argument('--entries');parser.add_argument('--table');args=parser.parse_args()
if os.environ.get('NUMBERDB_KEY_FROM_STDIN')=='1':numberdb.configure(api_key=sys.stdin.read().strip())
rows=records_of(numberdb.table(args.table)) if args.table else json.loads(Path(args.entries).read_text())
actual=[str(row['params']['r']) for row in rows];failures=[];comparisons=[];cache={}
if actual!=expected_selection():failures.append('Independent enumeration/order mismatch')
for row in rows:
r=rational(row['params']['r']);v,ds=event_sum(r);cache[str(r)]=(v,ds)
alt_x=reciprocal_product(r);alternate=alt_x+ds['Px']+ds['Py']+ds['D']
partition=ds['partition']
partition_ok=bool(partition.is_finite() and partition.contains_zero() and
partition.rad_as_ball().upper()<(F(10)**-130).lower())
passed=matches(row['number'],v) and matches(row['number'],alternate) and partition_ok
if not passed:failures.append('Mismatch, vacuous ball or partition failure at r='+str(r))
comparisons.append({'r':str(r),'stored':row['number'],'event_sum_ball':str(v),
'accuracy_bits':int(v.accuracy()),'absolute_radius_upper':str(v.rad_as_ball().upper()),
'reciprocal_product_event_ball':str(alternate),'partition_residual':str(partition),
'diagonal_tail_bound':str(ds['tail'].upper()),'max_homology_index':ds['M'],
'partition_sum_bounds':ds['box'],'passed':bool(passed)})
square,sd=cache['1'];sample=rows[0]['number'];lo,hi,ulp=decimal_interval(sample)
known=matches('0.690473725',square)
controls={'published_square':known,
'ten_ulp_shift_rejected':not matches(sample,square+10*F(ulp)),
'two_colors_rejected':not matches(sample,2*square),
'cross_topology_rejected':not matches(sample,sd['X']),
'horizontal_rejected':not matches(sample,sd['X']+sd['Px']+sd['D']),
'both_directions_rejected':not matches(sample,sd['X']+sd['D']),
'one_slope_rejected':not matches(sample,sd['X']+sd['Px']+sd['Py']+sd['D']/2),
'diagonal_as_cross_rejected':not matches(sample,residue_probability(QQ(1),1,1)+sd['Px']+sd['Py']+sd['D']),
'exact_zero_rejected':not matches(sample,F(0)),
'nan_rejected':not matches(sample,F('nan')),
'wide_ball_rejected':not matches(sample,F(0).add_error(100))}
# Nonsquare, nonaxial geometry control: replace only a^2/r by a^2*r.
good=residue_probability(QQ(2),1,2)
wrong=residue_probability(QQ(1),1,3)*eta(QQ(1))**2/eta(QQ(2))**2/F(2).sqrt()
controls['one_coordinate_aspect_error_rejected']=not same(good,wrong)
rotation=[]
for r_text,(v,ds) in cache.items():
inv=str(1/rational(r_text));rot,_=event_sum(rational(inv))
residual=v-rot
ok=bool(residual.is_finite() and residual.contains_zero() and residual.rad_as_ball().upper()<(F(10)**-130).lower())
rotation.append({'r':r_text,'reciprocal':inv,'residual':str(residual),'passed':ok})
if not ok:failures.append('Axis exchange identity failed: '+r_text)
for key,passed in controls.items():
if not passed:failures.append('Control failed: '+key)
result={'checked_entries':len(rows),'total_entries':12,'failures':failures,
'known_answer_control':bool(known),'negative_control_rejected':all(controls.values()),
'controls':controls,'control_inputs':{'square_source':'Newman--Ziff (15): 0.690473725',
'nonsquare_nonaxial_correct':str(good),'nonsquare_nonaxial_wrong_metric':str(wrong)},
'comparisons':comparisons,'axis_exchange':rotation,'working_bits':BITS,
'method':'Bounded sum over disjoint homology events; original residue sums and original 2D partition sums; native eta. Separate reciprocal product.',
'limitations':'Builder-authored checking, not an independent actor verdict; shared CFT input and unproved physical identification.'}
print(json.dumps(result,indent=2))
if failures:raise SystemExit(1)
if __name__=='__main__':main()