back to table · edit · history · where entries came from · files · download
4070 bytes, as of the version from 2026-11-09 16:19 (current). Recorded here, not run.
"""Check T693's repaired Programs example with the unchanged attached generator.
Run with SageMath, placing generate.py, program-example.py and
document-before.json beside this file:
sage -python repair_check.py
Instruction provenance: agents/runs/20261109T161456Z-repair-skills/manifest.json.
Both archived skill files have SHA-256
886390324dd1971e381a43cf3b46b822ab0bc67d62f31d8481e29ec79556746b.
This is a repair execution/precision check, not an independent critique.
"""
import contextlib
import hashlib
import io
import json
from pathlib import Path
import re
import sys
import importlib.metadata
import numberdb.sage as numberdb
from sage.env import SAGE_VERSION
from sage.rings.rational_field import QQ
from sage.rings.real_arb import RealBallField
from sage.rings.real_mpfi import RealIntervalField
from generate import coefficient_polynomials, evaluate, BettinConreyAsymptotic
here = Path(__file__).resolve().parent
source = here / 'generate.py'
assert hashlib.sha256(source.read_bytes()).hexdigest() == 'a9d546726f40e5607badc6107ec43f2e66f844f7c02bf6e14be39f825be42eec'
doc = json.loads((here / 'document-before.json').read_text())
old_scope = {}
exec(doc['Programs']['program-sage']['code'], old_scope)
assert len(old_scope['values']) == 61
capture = io.StringIO()
new_scope = {}
with contextlib.redirect_stdout(capture):
exec((here / 'program-example.py').read_text(), new_scope)
assert new_scope['ell'] == 61
p = coefficient_polynomials(61)[61]
assert p.degree() == 61
value = evaluate(p, digits=100)
high = p(RealBallField(800).pi() ** 2)
assert value.is_finite() and high.is_finite()
assert value.accuracy() >= numberdb.bits(100)
assert high.accuracy() >= 700
interval = RealIntervalField(1000)(value)
high_interval = RealIntervalField(1000)(high)
assert interval.lower() < high_interval.lower() and high_interval.upper() < interval.upper()
assert list(BettinConreyAsymptotic().enumerate()) == [{'ell': n} for n in range(61)]
# Parse the exact last-place intervals, rather than testing rounded midpoints.
def decimal_q(text):
sign, whole, frac, exponent = re.fullmatch(r'([+-]?)(\d+)(?:\.(\d*))?(?:[eE]([+-]?\d+))?', str(text)).groups()
frac = frac or ''
scale = int(exponent or 0) - len(frac)
return QQ((-1 if sign == '-' else 1) * int(whole + frac)) * QQ(10)**scale, QQ(10)**scale
block=doc['Numbers']
if isinstance(block,list):
entries=block
else:
entries=[]
for key,record in block.items():
entries.append({'params':{'ell':str(key)}, 'number':record})
checks=[]
for record in entries:
ell=int(record['params']['ell'])
poly=coefficient_polynomials(61)[ell]
if ell==0:
assert poly == 1 and str(record['number']) == '1'
checks.append({'ell':ell,'exact':True})
continue
center,ulp=decimal_q(record['number'])
ball=poly(RealBallField(800).pi()**2)
assert ball.is_finite() and ball.accuracy() >= 700
assert ball > center-ulp and ball < center+ulp
checks.append({'ell':ell,'accuracy_bits':int(ball.accuracy()),'stored_interval_contains_ball':True})
assert len(checks)==61
result={
'table':'T693',
'skill_manifest':'agents/runs/20261109T161456Z-repair-skills/manifest.json',
'skill_local_sha256':'886390324dd1971e381a43cf3b46b822ab0bc67d62f31d8481e29ec79556746b',
'skill_live_sha256':'886390324dd1971e381a43cf3b46b822ab0bc67d62f31d8481e29ec79556746b',
'sage_version':SAGE_VERSION,'numberdb_version':importlib.metadata.version('numberdb'),
'old_program_executes':True,'new_program_executes':True,
'new_program_stdout':capture.getvalue().strip(),
'order_61_working_accuracy_bits':int(value.accuracy()),
'order_61_high_precision_accuracy_bits':int(high.accuracy()),
'order_61_high_precision_ball_contained':True,
'default_enumeration_unchanged':True,
'stored_values_checked':len(checks),'stored_value_checks':checks,
'scope':'Executed both snippets and evaluated unchanged generator polynomials with propagated Arb pi uncertainty; not an independent derivation of the sequence or a critique.'}
print(json.dumps(result,indent=2))