Script: verify_bridge.py
Euler Signal Bridge
verify_bridge.py
This is the original source text. Reading it does not run or verify the program.
1 """Exact FIR / Euler coefficient bridge and reproducible signal-response figure.
2
3 Run: python verify_bridge.py
4 All arithmetic assertions use Python integers. The figure's frequency curves
5 use NumPy floating point and illustrate the filter, not an Euler DTFT.
6 """
7 from datetime import datetime, timezone
8 from math import comb
9 from pathlib import Path
10 import hashlib
11 import json
12 import platform
13 import sys
14 import time
15
16 import matplotlib
17 matplotlib.use("Agg")
18 import matplotlib.pyplot as plt
19 import numpy as np
20
21 ROOT = Path(__file__).resolve().parent
22
23
24 def mul(a, b):
25 out = [0] * (len(a) + len(b) - 1)
26 for i, x in enumerate(a):
27 for j, y in enumerate(b):
28 out[i + j] += x * y
29 return out
30
31
32 def transfer_row(m, s, k):
33 """Coefficients of (1+t)^s ((1+t)^m - 1)^k."""
34 base = [0] + [comb(m, j) for j in range(1, m + 1)]
35 out = [comb(s, j) for j in range(s + 1)]
36 for _ in range(k):
37 out = mul(out, base)
38 return out
39
40
41 def forward_difference(values, order, start=0, stride=1):
42 """Direct sample-space FIR stencil, independent of polynomial multiplication."""
43 return sum((-1) ** (order - j) * comb(order, j)
44 * values[start + stride * j] for j in range(order + 1))
45
46
47 def euler_even(count):
48 """Signed Euler convention: cosh(t) * sech(t) = 1."""
49 out = [1]
50 for n in range(1, count):
51 out.append(-sum(comb(2 * n, 2 * j) * out[j] for j in range(n)))
52 return out
53
54
55 def pad(values, n):
56 return values + [0] * (n - len(values))
57
58
59 def main():
60 started = datetime.now(timezone.utc).isoformat()
61 clock = time.perf_counter()
62 a = euler_even(48)
63 c = [forward_difference(a, r) for r in range(len(a))]
64 assert a[:5] == [1, -1, 5, -61, 1385]
65 assert c[:5] == [1, -2, 8, -80, 1664]
66 counts = {"Euler_coefficient_transfer": 0, "integer_signal_transfer": 0,
67 "refinement_composition_rows": 0, "prime_residual_polynomials": 0}
68 integer_signal = [(n * n * n - 7 * n + 3) * (-1) ** n for n in range(48)]
69 for values, label in [(a, "Euler_coefficient_transfer"),
70 (integer_signal, "integer_signal_transfer")]:
71 coefficients = [forward_difference(values, r) for r in range(48)]
72 for m in range(1, 6):
73 for s in range(m):
74 for k in range(7):
75 row = transfer_row(m, s, k)
76 actual = sum(w * coefficients[r] for r, w in enumerate(row))
77 expected = forward_difference(values, k, s, m)
78 assert actual == expected, (label, m, s, k)
79 counts[label] += 1
80 for m in range(1, 4):
81 for n in range(1, 4):
82 for s in range(m):
83 for t in range(n):
84 for ell in range(5):
85 second = transfer_row(n, t, ell)
86 combined = [0] * (m * n * ell + m * t + s + 1)
87 for k, w in enumerate(second):
88 first = transfer_row(m, s, k)
89 for r, coefficient in enumerate(first):
90 combined[r] += w * coefficient
91 direct = transfer_row(m * n, m * t + s, ell)
92 assert combined == pad(direct, len(combined))
93 counts["refinement_composition_rows"] += 1
94 for p in [2, 3, 5, 7, 11]:
95 # Phi_p(t) = t^p + p B_p(t), with B_p integral.
96 row = transfer_row(p, 0, 1)
97 assert row[0] == 0 and row[p] == 1
98 assert all(row[j] % p == 0 for j in range(1, p))
99 counts["prime_residual_polynomials"] += 1
100
101 outputs = [forward_difference(a, 1, stride=m) for m in [1, 2, 4]]
102 assert outputs == [-2, 4, 1384]
103 assert 2 * c[1] + c[2] == 4
104 assert 2 * 4 + 1376 == 1384
105 assert 4 * c[1] + 6 * c[2] + 4 * c[3] + c[4] == 1384
106 result = {"status": "PASS", "exact_cases": sum(counts.values()),
107 "checks": counts, "Euler_initial_values": a[:5],
108 "Euler_binomial_coefficients": c[:5],
109 "first_difference_outputs_at_spacing_1_2_4": outputs,
110 "scope": "Finite exact controls of the derived operator identities; no universal congruence inferred from this run."}
111 result_path = ROOT / "exact_results.json"
112 result_path.write_text(json.dumps(result, indent=2) + "\n")
113
114 plt.rcParams.update({"font.family": "DejaVu Sans", "font.size": 12,
115 "axes.spines.top": False, "axes.spines.right": False})
116 fig, axes = plt.subplots(2, 3, figsize=(13, 7.0))
117 fig.patch.set_facecolor("#fbfaf7")
118 colors = ["#256c87", "#ad5b32", "#65528a"]
119 omega = np.linspace(0, np.pi, 1001)
120 for col, (m, color, output) in enumerate(zip([1, 2, 4], colors, outputs)):
121 ax = axes[0, col]
122 ax.set_facecolor("#fbfaf7")
123 # Forward-index stencil a[n+m] - a[n].
124 ax.axhline(0, color="#8a8a8a", linewidth=0.8)
125 ax.vlines([0, m], 0, [-1, 1], color=color, linewidth=3)
126 ax.scatter([0, m], [-1, 1], color=color, s=70, zorder=3)
127 ax.set(xlim=(-0.5, 4.5), ylim=(-1.35, 1.35), xticks=range(5),
128 yticks=[-1, 0, 1], xlabel="Sample offset", ylabel="Tap weight")
129 ax.set_title(f"Spacing {m}: a[n+{m}] − a[n]", fontsize=13, pad=14)
130 ax.text(0.5, -0.38, f"Euler output at n = 0: {output:,}",
131 transform=ax.transAxes, ha="center", color=color, fontsize=12)
132 ax = axes[1, col]
133 ax.set_facecolor("#fbfaf7")
134 gain = np.abs(np.exp(1j * m * omega) - 1)
135 ax.plot(omega / np.pi, gain, color=color, linewidth=2.5)
136 ax.set(xlim=(0, 1), ylim=(-0.08, 2.18), xticks=[0, 0.5, 1],
137 yticks=[0, 1, 2], xlabel="Frequency ω / π", ylabel="Filter gain |H(ω)|")
138 ax.grid(alpha=0.18)
139 fig.suptitle("One difference filter, two mathematical readings", x=0.07,
140 ha="left", fontsize=21, fontweight="bold", y=0.98)
141 fig.text(0.07, 0.915,
142 "Top: exact integer taps and Euler outputs. Bottom: response to sinusoidal signals.", fontsize=12)
143 fig.text(0.07, 0.025,
144 "The response belongs to the filter. No Fourier spectrum is assigned to the growing Euler sequence.",
145 fontsize=11, color="#555555")
146 fig.subplots_adjust(left=0.075, right=0.975, top=0.80, bottom=0.115,
147 hspace=0.95, wspace=0.35)
148 image_path = ROOT / "Komorebi_Euler_Signal_Bridge.png"
149 fig.savefig(image_path, dpi=170, facecolor=fig.get_facecolor())
150 plt.close(fig)
151
152 manifest = {
153 "schema_version": 1,
154 "claim_id": "EulerSignalBridge-FIR-2026-10-09",
155 "repository": {"commit": "standalone script; no Git repository", "dirty": True},
156 "command": "python verify_bridge.py",
157 "environment": {"software": [f"Python {platform.python_version()}",
158 f"NumPy {np.__version__}",
159 f"Matplotlib {matplotlib.__version__}"],
160 "hardware": f"{platform.system()} {platform.machine()}; CPU only"},
161 "mathematics": {
162 "assertion_tested": "FIR stencil equals finite binomial-coordinate transfer; successive affine transfers compose; prime residual coefficients are integral.",
163 "coefficient_domain": "Python arbitrary-precision integers for all arithmetic checks; float64 only for illustrative frequency curves",
164 "conventions": "Signed Euler EGF sech(t); a(n)=E_(2n); advance shift S a(n)=a(n+1); Delta=S-I.",
165 "inputs": ["Signed Euler sequence through E_94", "deterministic alternating cubic integer signal", "affine transfer polynomial rows"],
166 "bounds": {"sample_count": 48, "transfer_M": [1, 5], "phase_s": "0 <= s < M", "difference_k": [0, 6], "composition_M_N": [1, 3], "composition_order": [0, 4], "primes": [2, 3, 5, 7, 11]},
167 "non_claims": ["No Fourier transform of the Euler sequence", "No universal Euler congruence follows from finite checks", "No novelty claim for the FIR or binomial identities", "No Lean build performed"]},
168 "randomness": {"used": False, "generator": "none", "seed": None},
169 "run": {"started_at": started, "runtime_seconds": time.perf_counter() - clock, "exit_status": 0},
170 "outputs": [{"path": p.name, "sha256": hashlib.sha256(p.read_bytes()).hexdigest()}
171 for p in [result_path, image_path]],
172 "checks": ["direct sample stencil versus independently expanded polynomial rows", "exact composition coefficient comparison", "small hand-computable Euler controls", "prime coefficient divisibility"],
173 "result": f"PASS: {sum(counts.values())} exact finite assertions plus initial-value controls.",
174 "residual_risks": ["A version 1 manifest records limited execution provenance; the script hash is separately supplied.", "Full-branch valuation bounds require a separate mathematical argument."]}
175 (ROOT / "computation_manifest.json").write_text(json.dumps(manifest, indent=2) + "\n")
176 (ROOT / "SOURCE_SHA256.txt").write_text(hashlib.sha256(Path(__file__).read_bytes()).hexdigest() + " verify_bridge.py\n")
177 print(json.dumps(result, indent=2))
178
179
180 if __name__ == "__main__":
181 main()
Original file and source record
This copy matches the recorded source file. Its publication here does not change the work’s review status.
SHA-256: 61096e40fb043d534401446f7982edd82ad8ef7890c5f4459fa5dfecc23e271e