Datasets:
Languages:
English
Size:
< 1K
ArXiv:
Tags:
nanofabrication
photochemistry
photonics
mathematical-physics
optimal-control
reaction-diffusion
Download code/audit_independent.py from PureOne/ELYRION-III: direct link, hf CLI and curl.
- Browser
- Download file 2.71 kB
-
https://huggingface.co/datasets/PureOne/ELYRION-III/resolve/main/code/audit_independent.py
- Command line
-
hf download hf://datasets/PureOne/ELYRION-III/code/audit_independent.py
-
curl -L -o audit_independent.py https://huggingface.co/datasets/PureOne/ELYRION-III/resolve/main/code/audit_independent.py
2.71 kB
| #!/usr/bin/env python3 | |
| """Separate implementations; deliberately does not import model.py. | |
| Exact Fraction matrices and high-precision evaluations provide finite audit | |
| coverage. High-precision arithmetic is not presented as an interval proof. | |
| """ | |
| from fractions import Fraction as F | |
| from pathlib import Path | |
| import json | |
| import random | |
| import mpmath as mp | |
| ROOT=Path(__file__).resolve().parents[1] | |
| random.seed(19311020) | |
| checks=[] | |
| def chk(name, ok): | |
| checks.append({'name':name,'passed':bool(ok)}) | |
| if not ok: raise AssertionError(name) | |
| def mv(matrix,vector): | |
| return [sum((a*b for a,b in zip(row,vector)),F(0)) for row in matrix] | |
| def eye(): | |
| return [[F(int(i==j)) for j in range(4)] for i in range(4)] | |
| filter_matrix=[[F(0),F(1),F(0),F(0)], | |
| [F(0),F(0),F(0),F(0)], | |
| [F(1),F(0),F(1),F(0)], | |
| [F(0),F(0),F(0),F(1)]] | |
| for case in range(80): | |
| state=[F(1),F(0),F(0),F(0)] | |
| remaining=F(1) | |
| for block in range(random.randrange(1,7)): | |
| survive=F(1) | |
| for j in range(random.randrange(1,12)): | |
| p=F(random.randrange(1,13),13) | |
| mm=eye(); mm[0][0]=1-p; mm[1][0]=p | |
| state=mv(filter_matrix,mv(mm,state)) | |
| survive*=p | |
| b=F(random.randrange(1,17),17) | |
| commit=[[1-b,F(1),F(1),F(0)], | |
| [F(0),F(0),F(0),F(0)], | |
| [F(0),F(0),F(0),F(0)], | |
| [b,F(0),F(0),F(1)]] | |
| state=mv(commit,state) | |
| remaining*=1-b*survive | |
| chk(f'exact_multibatch_matrices_{case}', | |
| state==[remaining,F(0),F(0),1-remaining] and sum(state)==1) | |
| mp.mp.dps=70 | |
| data=json.loads((ROOT/'results'/'verification.json').read_text()) | |
| for row in data['dose_table']: | |
| if row['m'] not in [3,4,8,16,64,256]: continue | |
| m=row['m']; u=mp.mpf(str(row['action'])) | |
| value=mp.fprod(1-mp.exp(-u*(1-mp.cos(mp.pi*(2*j-1)/m))) for j in range(m)) | |
| chk(f'independent_70digit_midpoint_{m}_{row["q"]}',abs(value-mp.mpf(str(row['q'])))<mp.mpf('2e-12')) | |
| for q_string,c in data['cubic_constants'].items(): | |
| c=mp.mpf(str(c)) | |
| value=mp.fprod((1-mp.exp(-c*mp.pi**2*(2*r+1)**2/2))**2 for r in range(100)) | |
| chk(f'independent_70digit_limit_{q_string}',abs(value-mp.mpf(q_string))<mp.mpf('1e-13')) | |
| out={'project':'EVE / ELYRION III','imports_main_implementation':False, | |
| 'tests_passed':sum(x['passed'] for x in checks),'tests_total':len(checks), | |
| 'mpmath_decimal_digits':mp.mp.dps, | |
| 'status':'Exact rational and high-precision finite audit; not external review or interval proof.', | |
| 'tests':checks} | |
| (ROOT/'results'/'independent_audit.json').write_text(json.dumps(out,indent=2)) | |
| print(f'Independent audit: {out["tests_passed"]}/{out["tests_total"]} checks passed') | |