back to table · edit · history · where entries came from · files · download
2582 bytes, as of the version from 2026-11-09 18:56 (current). Recorded here, not run.
"""Validate the unchanged T695 values for the 20261109T181032Z prose repair.
Run: agents/sage.sh repair_check.py table-before.json generate.py instructions.json
Checks use the current live generator, exact arithmetic, and a separate stored-value control.
No values, selection or generator source are changed by this repair.
"""
import json, hashlib
from pathlib import Path
from math import gcd
import numberdb.sage as numberdb
from sage.env import SAGE_VERSION
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
import generate
base = Path(__file__).resolve().parent
doc=json.loads((base/'table-before.json').read_text())
R=PolynomialRing(ZZ,'X'); X=R.gen()
rows=[]
for N,weights in doc['Numbers'].items():
for k,forms in weights.items():
for i,entry in forms.items():
rows.append(((int(N),int(k),int(i)), R(entry['number'] if isinstance(entry,dict) else entry)))
control=36*X**10-691*X**8+2073*X**6-2073*X**4+691*X**2-36
assert rows[0]==((1,12,1),control)
gen=generate.EvenPeriodPolynomials()
enumerated=[tuple(int(p[key]) for key in ('N','k','i')) for p in gen.enumerate()]
assert enumerated==[identity for identity,p in rows]
results=[]
for identity,p in rows:
N,k,i=identity; w=k-2
assert p.degree()==w and p.leading_coefficient()>0
assert gcd(*(int(c) for c in p.list()))==1
assert all(p[j]==0 for j in range(1,w+1,2))
sign=p[0]*ZZ(N)**(w//2)/p[w]
assert sign in (-1,1)
assert all(p[w-j] == sign*p[j]*ZZ(N)**(w//2-j) for j in range(w+1))
if N==1:
relation=p+sum(p[j]*(X-1)**j*X**(w-j) for j in range(w+1))+sum(p[j]*(-1)**j*(X-1)**(w-j) for j in range(w+1))
assert relation==0 and p(1)==0 and p(-1)==0
assert generate.exact_polynomial(*identity)==p
results.append({'identity':identity,'exact_recomputation':'match','primitive':True,'positive_leading_coefficient':True,'even':True,'reciprocal_identity':True})
print('checked',identity,flush=True)
namespace={}
exec(doc['Programs']['program-sage']['code'], namespace)
assert namespace['p'].degree()==10
assert R([a//namespace['g'] for a in namespace['c']])==control
print(json.dumps({'table':'T695','sage':SAGE_VERSION,'entry_count':len(rows),'generator_sha256':hashlib.sha256((base/'generate.py').read_bytes()).hexdigest(),'instructions':json.loads((base/'instructions.json').read_text()),'checks':results,'program_control':'match','new_values':False,'scope':'Exact generator recomputation and algebraic checks; no new independent analytic L-value check is claimed.'},indent=2))