TFPT scientific source excerpt Original repository path: experiments/theory-contracts/original-admissible-source-closure-20261025/geometric_sector_response/source_geometric_machine.py Original file SHA-256: 88f78a5263e3860076e8d94a4699107ac458c2cdcaf106426880bc9a66624c21 Inclusive original lines: 1-170 Line numbers below refer to the original source. This bounded excerpt is source evidence; it is not a new proof/checker run. Conversation metadata and personal execution details are omitted where indicated. 000001 | """Evolve the ACTUAL conformally varied comparison Dirac operator. 000002 | 000003 | Probe metric g_eps=exp(2 eps h(w))(dx^2+dw^2). After unitary density transport, 000004 | D_eps=exp(-eps h/2) D_0 exp(-eps h/2), on the original fixed Pin domain. 000005 | The profile and eps are controlled inputs, not a law selected by P1. 000006 | No projection/reset occurs between steps. Finite normal-mode Galerkin runs 000007 | are compared with an analytic all-mode first-response formula. 000008 | """ 000009 | import argparse 000010 | import json 000011 | from pathlib import Path 000012 | 000013 | import numpy as np 000014 | 000015 | HERE=Path(__file__).resolve().parent 000016 | 000017 | 000018 | def require(condition,message): 000019 | if not condition: 000020 | raise RuntimeError(message) 000021 | 000022 | 000023 | def profile_values(w,profile): 000024 | if profile=='quadratic':return w*w,2*w 000025 | # A smooth even bump, zero near w=0 and both original physical boundaries. 000026 | # Its location/width are diagnostic inputs, not TFPT predictions. 000027 | r=(w-.5)/.25 000028 | f=np.zeros_like(w);derivative=np.zeros_like(w) 000029 | inside=abs(r)<1 000030 | rr=r[inside] 000031 | f[inside]=np.exp(1-1/(1-rr*rr)) 000032 | derivative[inside]=f[inside]*(-2*rr/(1-rr*rr)**2)/.25 000033 | return f,derivative 000034 | 000035 | 000036 | def dirac_block(nmax, epsilon, k, b=1,profile='collar_bump'): 000037 | # In the original Pin sector containing the normal zero branch, the 000038 | # allowed transverse H indices are even: E_m=pi*m, J=b. 000039 | modes=np.arange(-nmax,nmax+1) 000040 | nodes,weights=np.polynomial.legendre.leggauss(max(512,8*nmax)) 000041 | w=(nodes+1)/2; weights=weights/2 000042 | orders=np.arange(-2*nmax,2*nmax+1) 000043 | f,_=profile_values(w,profile) 000044 | moments=np.cos(np.pi*orders[:,None]*w[None,:])@(weights*np.exp(-epsilon*f)) 000045 | hankel=moments[(modes[:,None]+modes[None,:])+2*nmax] 000046 | d=b*(k+0.5j*np.pi*(modes[:,None]-modes[None,:]))*hankel 000047 | require(np.max(abs(d-d.conj().T))<1e-12,'Hermitian original Dirac block') 000048 | return modes,d,w,weights 000049 | 000050 | 000051 | def old_covariance(modes,k,b=1): 000052 | nmax=len(modes)//2 000053 | c=np.zeros((len(modes),len(modes)),complex) 000054 | c[nmax,nmax]=float(b*k<0) 000055 | for m in range(1,nmax+1): 000056 | indices=[nmax+m,nmax-m] 000057 | d=b*np.array([[0,k+1j*np.pi*m],[k-1j*np.pi*m,0]]) 000058 | c[np.ix_(indices,indices)]=(np.eye(2)-d/np.sqrt(k*k+np.pi*np.pi*m*m))/2 000059 | require(np.linalg.norm(c@c-c)<1e-12,'Original pure D sea') 000060 | return c 000061 | 000062 | 000063 | def run(nmax,epsilon,k,times,profile='collar_bump'): 000064 | modes,d,w,weights=dirac_block(nmax,epsilon,k,profile=profile) 000065 | c0=old_covariance(modes,k) 000066 | eigenvalues,q=np.linalg.eigh(d) 000067 | initial=np.zeros(len(modes),complex);initial[nmax]=1 000068 | coefficients=q.conj().T@initial 000069 | # e^(itD) on test functions gives the usual e^(-itE) annihilator phase. 000070 | vectors=q@(np.exp(1j*eigenvalues[:,None]*times[None,:])*coefficients[:,None]) 000071 | norm=np.sum(abs(vectors)**2,axis=0) 000072 | occupancy=np.sum(vectors.conj()*(c0@vectors),axis=0).real 000073 | require(np.max(abs(norm-1))<1e-11,'Unitary source recursion') 000074 | require(occupancy.min()>-1e-12 and occupancy.max()<1+1e-12,'CAR covariance positivity') 000075 | dt=times[1]-times[0] 000076 | step=(q*np.exp(1j*dt*eigenvalues)[None,:])@q.conj().T 000077 | repeated=initial.copy() 000078 | for _ in range(len(times)-1):repeated=step@repeated 000079 | recurrence_error=float(np.linalg.norm(repeated-vectors[:,-1])) 000080 | require(recurrence_error<1e-10,'Repeated source steps versus direct evolution') 000081 | # Eliminate every exterior mode algebraically, without projecting/resetting 000082 | # the physical recursion. For unitary U, C=P U Q need not equal B^*. 000083 | outside=np.arange(len(modes))!=nmax 000084 | K=step[nmax,nmax] 000085 | B=step[outside,nmax] 000086 | C=step[nmax,outside] 000087 | E=step[np.ix_(outside,outside)] 000088 | memory=[];wrong_memory=[];v=B.copy() 000089 | for _ in range(len(times)-1): 000090 | memory.append(C@v) 000091 | wrong_memory.append(B.conj()@v) 000092 | v=E@v 000093 | def reduced(kernel): 000094 | x=[1+0j] 000095 | for n in range(len(times)-1): 000096 | x.append(K*x[-1]+sum(kernel[n-1-j]*x[j] for j in range(n))) 000097 | return np.asarray(x) 000098 | reduced_response=reduced(memory) 000099 | memory_error=float(np.max(abs(reduced_response-vectors[nmax]))) 000100 | wrong_memory_error=float(np.max(abs(reduced(wrong_memory)-vectors[nmax]))) 000101 | require(memory_error<1e-10,'Derived full source memory versus full evolution') 000102 | if abs(epsilon)>=.01: 000103 | require(wrong_memory_error>1e-7,'Incorrect adjoint memory control did not fire') 000104 | column=d[:,nmax].copy();column[nmax]=0 000105 | measured_return=float(np.linalg.norm(column)**2) 000106 | f,df=profile_values(w,profile) 000107 | mean=float(weights@np.exp(-epsilon*f)) 000108 | mean2=float(weights@np.exp(-2*epsilon*f)) 000109 | normal2=float(weights@(df*df*np.exp(-2*epsilon*f))) 000110 | exact_return=k*k*(mean2-mean*mean)+epsilon*epsilon*normal2/4 000111 | weak_coefficient=k*k*(weights@(f*f)-(weights@f)**2)+(weights@(df*df))/4 000112 | # Transport the canonical zero-mode particle (or hole for k<0) on the 000113 | # SAME history as the old sea. Their covariance difference is a single 000114 | # transported rank-one operator. This is a relative source response, 000115 | # not an identification with the primitive geometric action force. 000116 | orders=np.arange(-2*nmax,2*nmax+1) 000117 | derivative_moments=np.cos(np.pi*orders[:,None]*w[None,:])@(weights*(-f)*np.exp(-epsilon*f)) 000118 | derivative=(k+0.5j*np.pi*(modes[:,None]-modes[None,:]))*derivative_moments[(modes[:,None]+modes[None,:])+2*nmax] 000119 | state_vectors=q@(np.exp(-1j*eigenvalues[:,None]*times[None,:])*coefficients[:,None]) 000120 | defect_sign=1 if k>=0 else -1 000121 | geometry_response=defect_sign*np.sum(state_vectors.conj()*(derivative@state_vectors),axis=0).real 000122 | defect_energy=defect_sign*np.sum(state_vectors.conj()*(d@state_vectors),axis=0).real 000123 | energy_error=float(np.max(abs(defect_energy-defect_sign*k*mean))) 000124 | require(energy_error<1e-10,'Same-history relative defect energy conservation') 000125 | return dict(nmax=nmax,mode_count=len(modes),epsilon=epsilon,k=k, 000126 | return_form_finite=measured_return,return_form_all_mode=exact_return, 000127 | return_form_missing_tail=exact_return-measured_return, 000128 | weak_geometry_return_coefficient=float(weak_coefficient), 000129 | recurrence_error=recurrence_error,norm_error=float(np.max(abs(norm-1))), 000130 | derived_memory_error=memory_error,incorrect_adjoint_memory_error=wrong_memory_error, 000131 | memory_kernel=[[float(z.real),float(z.imag)] for z in memory], 000132 | times=times.tolist(),zero_branch_survival=(abs(vectors[nmax])**2).tolist(), 000133 | original_sea_zero_mode_occupancy=occupancy.tolist(), 000134 | relative_defect_sign=defect_sign, 000135 | relative_defect_geometry_response=geometry_response.tolist(), 000136 | relative_defect_energy=defect_energy.tolist(), 000137 | relative_defect_energy_conservation_error=energy_error, 000138 | relative_defect_source_scope='Same original sea and zero-mode particle/hole, evolved together; not primitive action identification', 000139 | final_occupancy=float(occupancy[-1])) 000140 | 000141 | 000142 | def main(): 000143 | parser=argparse.ArgumentParser(description=__doc__) 000144 | parser.add_argument('--epsilon',type=float,default=.1) 000145 | parser.add_argument('--profile',choices=['collar_bump','quadratic'],default='collar_bump') 000146 | parser.add_argument('--output',type=Path,default=HERE/'runs/source_geometric_machine.json') 000147 | args=parser.parse_args() 000148 | require(abs(args.epsilon)<=.5,'Use a bounded geometric probe |epsilon|<=0.5') 000149 | times=np.linspace(0,4,401) 000150 | k=np.pi/2 # Actual b=+1,c=+i old quarter-circle lowest positive momentum. 000151 | runs=[run(n,args.epsilon,k,times,args.profile) for n in [16,32,64,128]] 000152 | convergence=[] 000153 | for a,b in zip(runs,runs[1:]): 000154 | convergence.append(dict(n_from=a['nmax'],n_to=b['nmax'], 000155 | max_survival_difference=float(np.max(abs(np.array(a['zero_branch_survival'])-b['zero_branch_survival']))), 000156 | max_occupancy_difference=float(np.max(abs(np.array(a['original_sea_zero_mode_occupancy'])-b['original_sea_zero_mode_occupancy']))), 000157 | max_relative_defect_geometry_response_difference=float(np.max(abs(np.array(a['relative_defect_geometry_response'])-b['relative_defect_geometry_response']))))) 000158 | result=dict(source='Actual fixed Pin Dirac conformal metric variation; same initial pure D sea', 000159 | metric_profile=args.profile+'; explicitly chosen diagnostic profile', 000160 | native_input='b=+1,c=+i,q=i,k=pi/2; all compatible transverse modes retained up to stated Galerkin bound', 000161 | analytic_zero_geometry_return_coefficient='k^2 Var(f)+/4', 000162 | runs=runs,convergence=convergence, 000163 | scope='All-mode first-response form proved analytically; finite-mode unitary CAR evolution is numerically tested. No primitive history selection or P1 physical map claimed.', 000164 | physical_gates_closed=[],complete_TFPT_solution=False) 000165 | args.output.parent.mkdir(parents=True,exist_ok=True) 000166 | args.output.write_text(json.dumps(result,indent=2)+'\n') 000167 | print(json.dumps(dict(runs=[{key:value for key,value in x.items() if key not in ['times','zero_branch_survival','original_sea_zero_mode_occupancy','memory_kernel','relative_defect_geometry_response','relative_defect_energy']} for x in runs],convergence=convergence),indent=2)) 000168 | 000169 | 000170 | if __name__=='__main__':main()