"""Bounded arithmetic audit; no original research programs executed.
Predefined check: recompute all supplied P1 CSV values from the stated 0.18 law;
compare six prose-table rows against their same-input formula values, tolerance
0.01 meV for rounded prose. No real-data or physical-validity test is attempted.
"""
from pathlib import Path
from decimal import Decimal as D
import csv,json,argparse
root=Path(__file__).resolve().parents[2]
args=argparse.ArgumentParser()
args.add_argument('--source',type=Path,default=root/'work/research-packages/nov1-results-20261101/sources/Incoprea_E4_H034_2026-11-01')
src=args.parse_args().source
out=Path(__file__).parent
rows=[]
with (src/'results/h034_results.csv').open() as f:
 for r in csv.DictReader(f):
  if r['part']!='P1':continue
  expected=D('180')*D(r['P_eV'])**2/(D(r['kappa'])*D(r['Rc_A'])**3)
  rows.append({'P_eV':r['P_eV'],'Rc_A':r['Rc_A'],'expected_meV':str(expected),'csv_meV':r['E_out_meV'],'matches':abs(expected-D(r['E_out_meV']))<D('0.000000001')})
published=[(1,4,'11.25'),(2,4,'45.00'),(3,4,'101.25'),(6,4,'405.00'),(3,6,'30.00'),(3,8,'12.66')]
prose=[{'P_eV':p,'Rc_A':rc,'published_meV':v,'corrected_meV':str(D('180')*D(p)**2/D(rc)**3)} for p,rc,v in published]
assert len(rows)==12 and all(r['matches'] for r in rows)
(out/'h034-arithmetic.json').write_text(json.dumps({'test':'formula arithmetic only','csv_rows':rows,'prose_table':prose,'conclusion':'CSV matches formula; six prose table energies are approximately fourfold too high'},indent=2))
print(json.dumps(prose,indent=2))
