Datasets:
Formats:
json
Languages:
English
Size:
< 1K
Tags:
mathematical-physics
arrow-of-time
temporal-irreversibility
time-reversal-symmetry
quantum-information
quantum-foundations
Download verification/verify_quantum.py from PureOne/Neixarua-Operational-Temporal-Orientation: direct link, hf CLI and curl.
- Browser
- Download file 3.97 kB
-
https://huggingface.co/datasets/PureOne/Neixarua-Operational-Temporal-Orientation/resolve/main/verification/verify_quantum.py
- Command line
-
hf download hf://datasets/PureOne/Neixarua-Operational-Temporal-Orientation/verification/verify_quantum.py
-
curl -L -o verify_quantum.py https://huggingface.co/datasets/PureOne/Neixarua-Operational-Temporal-Orientation/resolve/main/verification/verify_quantum.py
3.97 kB
| """Finite reproducible checks for the quantum theorem module; no empirical claims.""" | |
| from __future__ import annotations | |
| import json | |
| from pathlib import Path | |
| import numpy as np | |
| from scipy.linalg import eigh, solve_sylvester | |
| I=np.eye(2,dtype=complex) | |
| X=np.array([[0,1],[1,0]],dtype=complex) | |
| Y=np.array([[0,-1j],[1j,0]],dtype=complex) | |
| Z=np.diag([1,-1]).astype(complex) | |
| def tr(a): return float(np.trace(a).real) | |
| def trace_norm(a): return float(np.abs(eigh((a+a.conj().T)/2,eigvals_only=True)).sum()) | |
| def entropy(a): | |
| e=eigh((a+a.conj().T)/2,eigvals_only=True) | |
| return float(-np.sum(e[e>1e-14]*np.log(e[e>1e-14]))) | |
| def js(a,b): return entropy((a+b)/2)-(entropy(a)+entropy(b))/2 | |
| def score(a,b): | |
| m=(a+b)/2; d=(a-b)/2 | |
| return solve_sylvester(m,m,2*d) | |
| def metric(a,b): | |
| l=score(a,b) | |
| return tr((a+b)/2@l@l) | |
| def dephase(a): return np.diag(np.diag(a)) | |
| r=.6; a=.4 | |
| rho=(I+r*X+a*Z)/2; sigma=(I+r*X-a*Z)/2 | |
| negative=(1-np.sqrt(1+r*r))/2 | |
| out={'scope':'Finite model calculations; not physical data or proof-assistant certificates.', | |
| 'counterexample':{'r':r,'a':a,'input_min_eigenvalue':float(min(eigh(rho,eigvals_only=True))), | |
| 'score_in':metric(rho,sigma),'score_out':metric(dephase(rho),dephase(sigma)), | |
| 'js_in':js(rho,sigma),'js_out':js(dephase(rho),dephase(sigma)), | |
| 'forced_recovery_min_eigenvalue':float(negative), | |
| 'helstrom_success_in':.5+.25*trace_norm(rho-sigma), | |
| 'helstrom_success_out':.5+.25*trace_norm(dephase(rho-sigma))}} | |
| # Amplitude-damping channel supplies nonzero noise and residual terms. | |
| g=.35 | |
| K=[np.array([[1,0],[0,np.sqrt(1-g)]],complex),np.array([[0,np.sqrt(g)],[0,0]],complex)] | |
| def phi(x): return sum(k@x@k.conj().T for k in K) | |
| def adj(x): return sum(k.conj().T@x@k for k in K) | |
| m=(rho+sigma)/2;l=score(rho,sigma); lp=score(phi(rho),phi(sigma)); pull=adj(lp) | |
| res=tr(m@(l-pull)@(l-pull)); schwarz=tr(m@(adj(lp@lp)-pull@pull));gap=metric(rho,sigma)-metric(phi(rho),phi(sigma)) | |
| out['score_loss_identity']={'channel':'amplitude damping','damping':g,'loss':gap,'residual':res,'schwarz_defect':schwarz,'absolute_residual':abs(gap-res-schwarz)} | |
| # Stinespring isometry V|psi> = sum_i K_i|psi> tensor |i>. | |
| V=np.zeros((4,2),complex) | |
| for j,k in enumerate(K): | |
| for b in range(2): V[2*b+j,:]=k[b,:] | |
| rBE=V@rho@V.conj().T;sBE=V@sigma@V.conj().T;mBE=(rBE+sBE)/2 | |
| # I(C:E|B)=S(CB)+S(BE)-S(B)-S(CBE). | |
| SCB=np.log(2)+(entropy(phi(rho))+entropy(phi(sigma)))/2 | |
| SCBE=np.log(2)+(entropy(rBE)+entropy(sBE))/2 | |
| cmi=SCB+entropy(mBE)-entropy(phi(m))-SCBE | |
| jsgap=js(rho,sigma)-js(phi(rho),phi(sigma)) | |
| out['js_stinespring_identity']={'js_loss':jsgap,'conditional_mutual_information':cmi,'absolute_residual':abs(jsgap-cmi)} | |
| # Protocol parity with transpose/conjugation J on Hermitian matrices. | |
| # Replacement with Y-biased state exactly saturates apparatus bound. | |
| b=.8;tau=(I+b*Y)/2 | |
| J=lambda q:q.conj() | |
| replace=lambda q:np.trace(q)*tau | |
| reversed_replace=lambda q:J(replace(J(q))) | |
| even=lambda q:(replace(q)+reversed_replace(q))/2 | |
| odd=lambda q:(replace(q)-reversed_replace(q))/2 | |
| s=(rho+J(rho))/2;d=(rho-J(rho))/2 | |
| out_actual=(replace(rho)-J(replace(rho)))/2 | |
| out_split=even(d)+odd(s) | |
| out['protocol_artifact']={'symmetric_input':trace_norm(d)<1e-14,'input_arrow':trace_norm(d),'output_arrow':trace_norm(out_actual),'apparatus_defect':b,'parity_identity_residual':trace_norm(out_actual-out_split)} | |
| checks=[abs(out['counterexample']['score_in']-a*a)<1e-12, | |
| abs(out['counterexample']['score_out']-a*a)<1e-12, | |
| negative<0, out['counterexample']['js_in']>out['counterexample']['js_out'], | |
| abs(gap-res-schwarz)<1e-12, res>=-1e-12, schwarz>=-1e-12, | |
| abs(jsgap-cmi)<1e-12, jsgap>0, | |
| trace_norm(out_actual-out_split)<1e-12, | |
| abs(trace_norm(out_actual)-b)<1e-12] | |
| out['verification']={'named_checks':len(checks),'passed':int(sum(checks)),'all_passed':all(checks),'absolute_tolerance':1e-12} | |
| path=Path(__file__).with_name('quantum_results.json') | |
| path.write_text(json.dumps(out,indent=2)+'\n') | |
| print(json.dumps(out,indent=2)) | |
| if not all(checks): raise AssertionError('A quantum mathematical check failed.') | |