Datasets:
Languages:
English
Size:
< 1K
ArXiv:
Tags:
nanofabrication
photochemistry
photonics
mathematical-physics
optimal-control
reaction-diffusion
Download code/verify.py from PureOne/ELYRION-III: direct link, hf CLI and curl.
- Browser
- Download file 11.1 kB
-
https://huggingface.co/datasets/PureOne/ELYRION-III/resolve/main/code/verify.py
- Command line
-
hf download hf://datasets/PureOne/ELYRION-III/code/verify.py
-
curl -L -o verify.py https://huggingface.co/datasets/PureOne/ELYRION-III/resolve/main/code/verify.py
11.1 kB
| #!/usr/bin/env python3 | |
| """Deterministic, reproducible checks for ELYRION III. | |
| Run from any directory. Results are numerical evidence for supplied proofs, | |
| not experiments, proof-assistant verification, or global novelty certification. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| from fractions import Fraction as F | |
| from itertools import product | |
| import json | |
| from math import pi | |
| from pathlib import Path | |
| import platform | |
| import time | |
| import numpy as np | |
| import scipy | |
| from model import (A,B,X,C, transition, ideal_filter, finite_filter, ideal_commit, | |
| run_pass, fringes, comb_profile, log_midpoint_yield, optimal_action, | |
| limit_product_bounds, cubic_constant, repeated_commits, | |
| hazard_example, diffusion_comb) | |
| ROOT = Path(__file__).resolve().parents[1] | |
| def main() -> None: | |
| parser = argparse.ArgumentParser(description=__doc__) | |
| parser.add_argument('--output', type=Path, default=ROOT/'results'/'verification.json') | |
| parser.add_argument('--skip-diffusion', action='store_true') | |
| args = parser.parse_args() | |
| begin=time.perf_counter() | |
| rng=np.random.default_rng(20261020) | |
| tests=[] | |
| def check(name: str, condition: bool, **data): | |
| record={'name':name, 'passed':bool(condition), **data} | |
| tests.append(record) | |
| if not condition: | |
| raise AssertionError(record) | |
| # Exact rational recurrence, including commit and mass conservation. | |
| rational_cases=0 | |
| for m in range(1,7): | |
| for sample in range(20): | |
| ps=[F(int(rng.integers(1,10)),10) for _ in range(m)] | |
| state=[F(1),F(0),F(0),F(0)] | |
| expected=F(1) | |
| for p in ps: | |
| marked=state[A]*p | |
| state[A]-=marked; state[B]+=marked | |
| state=[state[B],F(0),state[X]+state[A],state[C]] | |
| expected*=p | |
| q=F(3,7) | |
| committed=q*state[A] | |
| state=[1-committed,F(0),F(0),committed] | |
| rational_cases+=1 | |
| check(f'exact_fraction_pass_{m}_{sample}', | |
| committed==q*expected and sum(state)==1 and min(state)>=0) | |
| for source,target in [(A,B),(A,X),(B,A),(A,C),(X,A)]: | |
| for action in [0.,.01,1.,10.,40.]: | |
| mat=transition(source,target,action) | |
| check(f'stochastic_transition_{source}_{target}_{action}', | |
| np.min(mat)>=0 and np.max(abs(mat.sum(axis=0)-1))<1e-14) | |
| for h in [.1,1.,3.,8.,16.]: | |
| ff=finite_filter(h,h) | |
| tv=np.max(np.sum(abs(ff-ideal_filter()),axis=0))/2 | |
| check(f'finite_filter_error_{h}',tv<=2*np.exp(-h)+1e-14, observed_tv=float(tv)) | |
| for m in range(2,17): | |
| theta=2*pi*np.arange(256*m)/(256*m) | |
| u=optimal_action(m,.5) | |
| s=comb_profile(m,u,theta) | |
| check(f'comb_range_{m}',s.min()>=0 and s.max()<=1+1e-14) | |
| check(f'comb_nodes_{m}',np.max(s[::256])<1e-24) | |
| check(f'comb_midpoints_{m}',np.max(abs(s[128::256]-.5))<2e-11) | |
| check(f'cyclic_symmetry_{m}',np.max(abs(s-np.roll(s,256)))<2e-12) | |
| ft=np.fft.rfft(s)/len(s) | |
| forbidden=np.arange(len(ft))%m!=0 | |
| check(f'forbidden_Fourier_modes_{m}',np.max(abs(ft[forbidden]))<1e-12) | |
| state=run_pass(fringes(m,theta),np.full(m,u),committed=.17) | |
| check(f'four_state_vs_product_{m}',np.max(abs(state[A]-.83*s))<2e-13) | |
| check(f'four_state_mass_{m}',np.max(abs(state.sum(axis=0)-1))<3e-13) | |
| # Removing the selection operation gives integrated dose, not the conjunction. | |
| no_filter=-np.expm1(-u*fringes(m,theta).sum(axis=0)) | |
| check(f'no_filter_is_uniform_{m}',np.ptp(no_filter)<2e-12) | |
| small=.0005 | |
| p0=np.prod(fringes(m,theta),axis=0) | |
| ss=comb_profile(m,small,theta)/small**m | |
| check(f'weak_gate_root_limit_{m}', | |
| np.max(ss-p0)<1e-12 and np.max(np.exp(-m*small/2)*p0-ss)<1e-12) | |
| # Noise budget at the nominal dark nodes, not a claim about all Fourier errors. | |
| delta=rng.uniform(-.03,.03,m) | |
| floor=.0001 | |
| nodes=2*pi*np.arange(m)/m | |
| pert=comb_profile(m,u,nodes,phases=nodes+delta,floor=floor) | |
| bound=-np.expm1(-u*(floor+2*np.sin(delta/2)**2)) | |
| check(f'dark_phase_floor_bound_{m}',np.max(pert-bound)<1e-13) | |
| allocation_trials=0 | |
| for m in [2,3,4,6,8,12]: | |
| u=optimal_action(m,.5) | |
| x=2*pi*(np.arange(m)+.5)/m | |
| for j in range(100): | |
| alloc=rng.dirichlet(np.ones(m))*m*u | |
| worst=float(comb_profile(m,alloc,x).min()) | |
| allocation_trials+=1 | |
| check(f'max_min_allocation_{m}_{j}',worst<=.5+1e-12) | |
| grid_allocation_count=0 | |
| for m in [2,3,4]: | |
| quanta=12 | |
| best=0.0 | |
| x=2*pi*(np.arange(m)+.5)/m | |
| for alloc in product(range(quanta+1),repeat=m-1): | |
| last=quanta-sum(alloc) | |
| if last<0: continue | |
| a=np.asarray((*alloc,last),dtype=float)/4 | |
| value=float(comb_profile(m,a,x).min()) | |
| best=max(best,value) | |
| grid_allocation_count+=1 | |
| exact=float(np.exp(log_midpoint_yield(m,quanta/(4*m)))) | |
| check(f'exhaustive_allocation_grid_{m}',abs(best-exact)<1e-13, | |
| maximum=float(best)) | |
| for j in range(100): | |
| a,b,g=rng.uniform(.001,20,3) | |
| separate=(-np.expm1(-a*g))*(-np.expm1(-b*g)) | |
| merged=-np.expm1(-(a+b)*g) | |
| check(f'repeated_node_consolidation_{j}',separate<=merged+1e-14) | |
| for case in range(100): | |
| m=int(rng.integers(2,10)) | |
| theta=2*pi*np.arange(257)/257 | |
| allocations=rng.uniform(.01,5,(3,m)) | |
| separate_remaining=np.ones(len(theta)) | |
| for aa in allocations: | |
| separate_remaining*=1-comb_profile(m,aa,theta) | |
| combined=comb_profile(m,allocations.sum(axis=0),theta) | |
| check(f'multipass_merge_domination_{case}', | |
| np.max((1-separate_remaining)-combined)<1e-13) | |
| constants={str(q):cubic_constant(q) for q in [.1,.5,.9,.99]} | |
| dose_rows=[] | |
| for q in [.1,.5,.9,.99]: | |
| c=constants[str(q)] | |
| for m in [2,3,4,8,16,32,64,128,256]: | |
| u=optimal_action(m,q) | |
| dose_rows.append(dict(m=m,q=q,action=u,total_action=m*u,ratio=u/m**2)) | |
| check(f'dose_inverse_{q}_{m}',abs(np.exp(log_midpoint_yield(m,u))-q)<2e-12) | |
| lower=m*(-np.log1p(-np.sqrt(q)))/(2*np.sin(pi/(2*m))**2) | |
| check(f'two_nearest_gate_lower_bound_{q}_{m}',m*u+2e-12*max(1.0,lower)>=lower) | |
| check(f'cubic_limit_{q}',abs(dose_rows[-1]['ratio']/c-1)<5e-5) | |
| for c in [.025,.05,.1,.25,.6,1.0]: | |
| for r in [1,2,4,8]: | |
| lo,hi=limit_product_bounds(c,r) | |
| ref=limit_product_bounds(c,64)[1] | |
| check(f'analytic_product_tail_{c}_{r}',lo-2e-15<=ref<=hi+2e-15) | |
| hazard_rows=[] | |
| for action in [.2,.1,.05,.025]: | |
| data=hazard_example(action) | |
| check(f'universal_hazard_bound_{action}',data['error']<=data['bound']+1e-13) | |
| check(f'universal_hazard_contraction_{action}',data['error']<=data['hazard_error']+1e-13) | |
| check(f'universal_hazard_probability_{action}', | |
| data['written'].min()>=0 and data['written'].max()<1) | |
| hazard_rows.append({k:v for k,v in data.items() if not isinstance(v,np.ndarray)}) | |
| check('hazard_example_convergence',all(hazard_rows[i+1]['error']<hazard_rows[i]['error'] | |
| for i in range(len(hazard_rows)-1))) | |
| for case in range(20): | |
| q=rng.uniform(.001,.4,15) | |
| scale=.03 | |
| coeff=float(rng.uniform(.001,.2)) | |
| logs,count,frac=repeated_commits(q,coeff,scale) | |
| remaining=np.ones(15) | |
| whole=int(np.floor(coeff/scale)) | |
| for _ in range(whole): remaining*=1-q | |
| remaining*=1-frac*q | |
| check(f'collapsed_finite_passes_{case}',np.max(abs(np.exp(logs)-remaining))<1e-13) | |
| # A single-pass retention ceiling is NOT a multi-pass impossibility theorem. | |
| single_lossy=(.8**4)*.9 | |
| two_lossy=1-(1-single_lossy)**2 | |
| check('retention_ceiling_is_single_pass_only',single_lossy<.5<two_lossy, | |
| one_pass=single_lossy,two_passes=two_lossy) | |
| diffusion_rows=[] | |
| if not args.skip_diffusion: | |
| for m in [2,3,4,6]: | |
| u=optimal_action(m,.5) | |
| for d in [0.,1e-6,1e-4,1e-3]: | |
| data=diffusion_comb(m,u,d) | |
| check(f'diffusion_positivity_{m}_{d}',data['survival'].min()>-1e-12) | |
| check(f'diffusion_subprobability_{m}_{d}',data['survival'].max()<1+1e-12) | |
| check(f'diffusion_dark_bound_{m}_{d}',np.max(data['dark']-data['bounds'])<2e-11) | |
| if d==0: | |
| ref=comb_profile(m,u,data['theta']) | |
| check(f'diffusion_zero_reduction_{m}',np.max(abs(ref-data['survival']))<1e-11) | |
| refinement=diffusion_comb(m,u,d,n=128*m) | |
| grid_error=float(abs(data['survival']-refinement['survival'][::2]).max()) | |
| check(f'diffusion_grid_refinement_{m}_{d}',grid_error<.002) | |
| diffusion_rows.append(dict(m=m,diffusion=d,action=u,time=data['time'], | |
| max_dark=float(data['dark'].max()),min_bright=float(data['bright'].min()), | |
| max_dark_bound=float(data['bounds'].max()),grid_error=grid_error, | |
| n=data['n'])) | |
| example_m=8 | |
| ex_u=optimal_action(example_m,.5) | |
| dark=.01 | |
| report=dict( | |
| project='EVE / ELYRION III',version='3.0',date='2026-10-20',seed=20261020, | |
| epistemic_status='ANALYTIC_PROOFS_PLUS_EXACT_RATIONAL_AND_FLOATING_TESTS; NO_EXPERIMENTS', | |
| tests_passed=sum(t['passed'] for t in tests),tests_total=len(tests), | |
| exact_rational_pass_cases=rational_cases,random_allocation_trials=allocation_trials, | |
| exhaustive_grid_allocations=grid_allocation_count, | |
| cubic_constants=constants,dose_table=dose_rows,hazard_examples=hazard_rows, | |
| diffusion_examples=diffusion_rows, | |
| m8_dark01_budget=dict(action=ex_u,total_action=example_m*ex_u, | |
| extinction_floor=-np.log1p(-dark)/ex_u, | |
| phase_radians=float(np.arccos(1+np.log1p(-dark)/ex_u))), | |
| environment=dict(python=platform.python_version(),numpy=np.__version__,scipy=scipy.__version__), | |
| elapsed_seconds=time.perf_counter()-begin,tests=tests, | |
| limitations=['No actual material is identified or characterized.', | |
| 'Floating tests and tail evaluations are not interval certificates.', | |
| 'Diffusion computations discretize the continuum PDE; refinement is numerical.', | |
| 'Cubic optimality is for the declared exact-node serial gate class only.', | |
| 'Positive 3D universality has no efficient runtime guarantee.']) | |
| args.output.parent.mkdir(parents=True,exist_ok=True) | |
| args.output.write_text(json.dumps(report,indent=2),encoding='utf-8') | |
| print(json.dumps({k:report[k] for k in ['tests_passed','tests_total','exact_rational_pass_cases', | |
| 'exhaustive_grid_allocations','elapsed_seconds']},indent=2)) | |
| print('Results:',args.output) | |
| if __name__=='__main__': | |
| main() | |