back to table · edit · history · where entries came from · files · download
1911 bytes, as of the version from 2026-11-28 03:17 (current). Recorded here, not run.
"""Check the inverse class-number conversion at every stored T842 modulus.
python3 paired_inverse_check.py
Reads actual stored rows and the roots/class numbers certified by
independent_check.py. This is an exact family consistency check, not an
independent critic or a new computation of either table's quantity.
"""
import json,hashlib
from pathlib import Path
def run(work):
rows=json.loads((work/'stored-rows.json').read_text());checked=json.loads((work/'stored-check-results.json').read_text())
fields={f['D']:f for f in checked['fields']};certs={(c['D'],c['p']):c for c in checked['comparisons']};results=[];failures=[]
for row in rows:
D,p=(int(row['params'][k]) for k in ('D','p'));c=certs[D,p];f=fields[D]
assert f['h']%p!=0 # true for this selection; general h needs its valuation propagated
root=int(c['root']);lam=int(c['companion_residue']);A=c['companion_A']+1
inverse=lam*p*root*pow(2*f['h']*(p-1),-1,p**A)%p**A
good=A>=row['A'] and (inverse-int(row['residue']))%p**row['A']==0
if not good:failures.append(dict(D=D,p=p))
results.append(dict(D=D,p=p,matched=good,inverse_A=A,stored_A=row['A'],inverse_residue=str(inverse)))
assert len(results)==107 and not failures
output=dict(table='T842',companion='T841',checked_entries=len(results),total_entries=len(rows),failures=failures,method='ell=p*r*lambda/(2*h*(p-1)); h is prime to each selected odd p; inverse gains one absolute digit',inputs={name:hashlib.sha256((work/name).read_bytes()).hexdigest() for name in ('stored-rows.json','stored-check-results.json','companion-stored-records.json')},comparisons=results)
(work/'paired-inverse-results.json').write_text(json.dumps(output,indent=2))
print('Inverse class-number conversion:',len(results),'of',len(rows),'matched at the full stored logarithm precision')
if __name__=='__main__':run(Path(__file__).parent)