TFPT scientific source excerpt Original repository path: experiments/theory-contracts/chat-triangulation-20261108/test_moving_original_cuts_20261108.py Original file SHA-256: 350817245e133a966350b350d473db180ba628fd6bf90920a6dadbb0aad41fde Inclusive original lines: 1-150 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 | """Deterministic probes of three TFPT moving-cut hypotheses.""" 000002 | 000003 | import importlib.util 000004 | import json 000005 | from pathlib import Path 000006 | import sys 000007 | 000008 | import numpy as np 000009 | from scipy.integrate import quad 000010 | import sympy as sp 000011 | 000012 | 000013 | def load_original(path, name): 000014 | spec = importlib.util.spec_from_file_location(name, path) 000015 | module = importlib.util.module_from_spec(spec) 000016 | spec.loader.exec_module(module) 000017 | return module 000018 | 000019 | 000020 | def collar_profile(w): 000021 | r = (w - .5) / .25 000022 | return np.exp(1 - 1 / (1 - r*r)) if abs(r) < 1 else 0. 000023 | 000024 | 000025 | def translation_test(pin): 000026 | # Constant normal translations fail the Pin deck relation. Test a 000027 | # deck-compatible flow instead: v(w)=sin(pi*w), zero at both ends. 000028 | _, pi = sp.symbols("w"), sp.pi 000029 | k = np.pi / 2 000030 | modes = np.arange(-1, 2) 000031 | sea = pin.old_covariance(modes, k) 000032 | tangent = np.array([np.pi / 4, 0., np.pi / 4]) 000033 | leakage = np.vdot(tangent, sea @ tangent).real 000034 | exact = pi**2 * (1 - 1 / sp.sqrt(5)) / 16 000035 | assert abs(leakage - float(exact)) < 2e-15 000036 | assert leakage > 0 000037 | return {"same_vacuum_leakage_norm_squared": leakage, 000038 | "exact": str(exact)} 000039 | 000040 | 000041 | def current_test(pin): 000042 | # Unit current, q=i. Extend the original even collar bump with a 000043 | # longitudinal harmonic that is not in the Möbius algebra. 000044 | mean, _ = quad(collar_profile, .25, .75, epsabs=1e-13) 000045 | alpha = .25 000046 | x, y = 1/16, 9/16 # centers of the original disjoint arc probes 000047 | s = x - y 000048 | c = np.exp(2j*np.pi*(alpha-1)*s) / (1 - np.exp(-2j*np.pi*s)) 000049 | ks = 2*np.pi*(np.arange(-4, 4) + alpha) 000050 | occ = (ks < 0).astype(float) 000051 | dc = 0j 000052 | nonzero_entries = 0 000053 | for i, ki in enumerate(ks): 000054 | for j, kj in enumerate(ks): 000055 | if abs(i-j) == 2 and occ[i] != occ[j]: 000056 | # Divided difference of the negative spectral projector 000057 | # on the original reducing zero branch at epsilon=0. 000058 | v = -mean*(ki+kj)/4 000059 | dc += (occ[i]-occ[j])/(ki-kj)*v*np.exp(1j*(ki*x-kj*y)) 000060 | nonzero_entries += 1 000061 | ward = -mean/(2*np.sqrt(2)) 000062 | spectral = -2*np.real(c.conjugate()*dc) 000063 | assert nonzero_entries == 4 000064 | assert abs(ward-spectral) < 2e-15 and ward != 0 000065 | 000066 | # The original normal-only bump vanishes near all boundary collars. 000067 | # Its mixed, omitted response is visible already at order epsilon^2. 000068 | m = np.arange(1, 65) 000069 | hm = np.array([2*quad(lambda w: collar_profile(w)*np.cos(np.pi*j*w), 000070 | .25, .75, epsabs=1e-13)[0] for j in m]) 000071 | 000072 | def positive_mode_gain(k): 000073 | energy = np.hypot(k, np.pi*m) 000074 | return float(np.sum(hm**2/16*((energy-k)/(energy+k))**2*(1-k/energy))) 000075 | 000076 | k = np.pi/2 000077 | gain = positive_mode_gain(k) 000078 | # All paired normal modes give a decreasing gain in |k|. For the 000079 | # half-circle pair the current correction is an alternating sum of 000080 | # two gains. Its first pair dominates its second. 000081 | j = np.arange(512) 000082 | pairs = np.array([positive_mode_gain(2*np.pi*(i+alpha)) 000083 | + positive_mode_gain(2*np.pi*(i+1-alpha)) for i in j]) 000084 | response = float(np.sum((-1.)**j*pairs)) 000085 | assert np.all(np.diff(pairs) < 0) and response > 0 000086 | direct = {} 000087 | for eps in [.01, .005, .0025]: 000088 | modes, d, _, _ = pin.dirac_block(64, eps, k) 000089 | eigenvalues, eigenvectors = np.linalg.eigh(d) 000090 | direct[str(eps)] = float(np.sum(abs(eigenvectors[64, eigenvalues < 0])**2)/eps**2) 000091 | assert abs(direct["0.0025"]-gain) < 2e-6 000092 | return {"unit_current_first_order": {"ward": ward, "spectral": spectral, 000093 | "absolute_error": abs(ward-spectral)}, 000094 | "normal_bump_current_order_2_estimate": response, 000095 | "normal_bump_cutoff_longitudinal_omission_bound": 000096 | positive_mode_gain(2*np.pi*(512+alpha)) + 000097 | positive_mode_gain(2*np.pi*(513-alpha)), 000098 | "normal_bump_first_two_pair_difference": float(pairs[0]-pairs[1]), 000099 | "normal_bump_positive_mode_order_2": gain, 000100 | "normal_bump_direct_occupation_over_epsilon_squared": direct} 000101 | 000102 | 000103 | def refinement_test(pin, v17): 000104 | k = np.pi/2 000105 | times = np.linspace(0, 4, 401) 000106 | low, high = [pin.run(n, .1, k, times) for n in (64, 128)] 000107 | 000108 | def curve_difference(key): 000109 | return float(np.max(np.abs(np.asarray(low[key])-high[key]))) 000110 | 000111 | # Exact spatial blocking on the original C6 Green component. Keep the 000112 | # eliminated scalar determinant along with the effective kernel. 000113 | a, b = sp.symbols("a b", positive=True) 000114 | u = v17.U6_power(1) 000115 | q = a*sp.eye(6) - b*(u+u.T) 000116 | keep, out = [0, 2, 4], [1, 3, 5] 000117 | s = q.extract(keep, keep) - q.extract(keep, out)*q.extract(out, out).inv()*q.extract(out, keep) 000118 | expected = (a-b*b/a)*sp.eye(3) - (b*b/a)*sp.ones(3) 000119 | assert (s-expected).applyfunc(sp.simplify) == sp.zeros(3) 000120 | assert sp.factor(q.det()-a**3*s.det()) == 0 000121 | assert sp.factor(q.inv()[0, 2]-s.inv()[0, 1]) == 0 000122 | delta = ((794-7*sp.sqrt(9961))/2187)**sp.Rational(1, 6) 000123 | rows = [] 000124 | for y in [sp.Integer(1), sp.Rational(1, 3), sp.Rational(2, 3)]: 000125 | aa = y*y+delta*delta 000126 | bb = y*delta 000127 | rows.append({"y": str(y), "retained_G_02": float(s.inv()[0, 1].subs({a:aa,b:bb})), 000128 | "omitted_logdet_if_discarding_exterior": float(3*sp.log(aa)), 000129 | "omitted_delta_derivative": float(6*delta/aa)}) 000130 | return {"pin_modes": [low["mode_count"], high["mode_count"]], 000131 | "pin_occupancy_curve_error": curve_difference("original_sea_zero_mode_occupancy"), 000132 | "pin_survival_curve_error": curve_difference("zero_branch_survival"), 000133 | "pin_peak_occupancy": max(high["original_sea_zero_mode_occupancy"]), 000134 | "pin_memory_vs_full_error": [low["derived_memory_error"], high["derived_memory_error"]], 000135 | "c6_three_sites_exact_schur_and_absolute_determinant": rows} 000136 | 000137 | 000138 | def main(root): 000139 | pin = load_original(root / "experiments/theory-contracts/" 000140 | "original-admissible-source-closure-20261025/" 000141 | "geometric_source_return/source_geometric_machine.py", "pin_original") 000142 | sys.path.insert(0, str(root / "verification")) 000143 | v17 = load_original(root / "verification/v17_hexagonal_resolvent.py", "v17_original") 000144 | print(json.dumps({"translation": translation_test(pin), 000145 | "current": current_test(pin), 000146 | "refinement": refinement_test(pin, v17)}, indent=2)) 000147 | 000148 | 000149 | if __name__ == "__main__": 000150 | main(Path(sys.argv[1]))