repair_delta_check.py

back to table · edit · history · where entries came from · files · download

2762 bytes, as of the version from 2026-11-09 18:48 (current). Recorded here, not run.

"""Verify the identity used by the T696 wording repair.
Run: sage -python repair_delta_check.py
Place generate.py and repair-skill-evidence.json beside this script.
Save GET /api/table?id=T696 as document-before.json and
GET /api/table?id=Q-expansion_of_the_modular_discriminant as delta-document.json.
The saved T696 document may precede or follow the prose-only repair.
The check itself uses no network or credentials.
"""
import hashlib, json
from pathlib import Path
from math import comb
import numberdb.sage
from sage.libs.pari import pari
from sage.rings.integer_ring import ZZ
from sage.rings.polynomial.polynomial_ring_constructor import PolynomialRing
from sage.version import version
import generate
p=Path(__file__).resolve().parent
M,C,S,rows=generate.space_data(1,12)
assert C.dimension()==S.dimension()==1 and len(rows)==1
assert rows[0]['i']==1 and rows[0]['field_degree']==1
# Integer eta-product coefficients, computed without modular-form software.
cutoff=100
eta=[1]+[0]*cutoff
for n in range(1,cutoff+1):
    new=[0]*(cutoff+1)
    for j in range(min(24,cutoff//n)+1):
        c=(-1)**j*comb(24,j)
        for m in range(cutoff-j*n+1): new[m+j*n]+=eta[m]*c
    eta=new
delta=[0]+eta[:cutoff]
assert delta[:6]==[0,1,-24,252,-1472,4830]
sage_q=rows[0]['factor'].q_eigenform(cutoff+1,names='a')
pari_forms=pari.mfeigenbasis(pari.mfinit([1,12],0))
assert len(pari_forms)==1
pari_q=pari.mfcoefs(pari_forms[0],cutoff)
linked=json.loads((p/'delta-document.json').read_text())['Numbers']
for n in range(cutoff+1):
    assert ZZ(sage_q[n])==ZZ(pari_q[n])==ZZ(delta[n])==ZZ(linked[str(n)])
doc=json.loads((p/'document-before.json').read_text())
R=PolynomialRing(ZZ,'X');X=R.gen()
stored=R(doc['Numbers']['1']['12']['1']['number'])
published_shape=X*(X**2-1)**2*(X**2-4)*(4*X**2-1)
assert stored==published_shape==generate.exact_polynomial(1,12,1)
result={'table':'T696','checked_identity':'f_{1,12,1}=Delta','method':'exact integer eta product versus Sage and independent PARI newform coefficients; linked live coefficient table; exact odd polynomial',
 'sage_version':version,'pari_version':str(pari.version()),'dimensions':{'cuspidal':int(C.dimension()),'new':int(S.dimension())},
 'coefficients_checked_inclusive':[0,cutoff],'all_equal':True,'odd_polynomial':str(stored),'odd_polynomial_matches':True,
 'source':'https://pmc.ncbi.nlm.nih.gov/articles/PMC4790983/ Example 1',
 'skill_evidence':json.loads((p/'repair-skill-evidence.json').read_text()),
 'inputs_sha256':{n:hashlib.sha256((p/n).read_bytes()).hexdigest() for n in ('generate.py','document-before.json','delta-document.json')},
 'scope':'Only the identity used in the wording repair was recomputed; the 18 stored values and selection are unchanged.'}
print(json.dumps(result,indent=2))