>[!warning]
>This content has not been peer reviewed.
# Super-Relational Mapping — Verification Calculation
Calculation logic for **[[Super-Relational Mapping Verification]]**. Outputs: identity tables and a figure (see [[Super-Relational Mapping Results]]).
---
## 1. Docstring and Imports
```python
"""
RST Super-Relational Mapping: Identity Proof
Proves that the Resource Triangle (W^n = Omega^n + N^n) and
the RST Field Equation (I = Omega * mu(Omega/N)) are the
same mathematical identity.
Outputs: log table and figure (see [[Super-Relational Mapping Results]])
"""
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import brentq
import os
import sys
```
---
## 2. Output Setup
```python
# Output directory (conceptual)
RESULTS_DIR = "results" # log and figure
os.makedirs(RESULTS_DIR, exist_ok=True)
LOG_PATH = os.path.join(RESULTS_DIR, "super_relational_mapping_log.txt")
class Tee:
"""Write to both stdout and a log file."""
def __init__(self, path):
self.terminal = sys.stdout
self.log = open(path, "w", encoding="utf-8")
def write(self, message):
self.terminal.write(message)
self.log.write(message)
def flush(self):
self.terminal.flush()
self.log.flush()
```
---
## 3. Parameters and Core Functions
```python
n_sharpness = 1.25 # n derived from Pure Axiom Substrate; SPARC confirms
N_FLOOR = 1.0 # normalized noise floor
def mu_rst(eta, n=n_sharpness):
"""RST interpolation: mu(eta,n) = eta / (1 + eta^n)^(1/n)"""
return eta / (1.0 + eta**n)**(1.0/n)
def triangle_W(Omega, N, n=n_sharpness):
"""Total budget: W = (Omega^n + N^n)^(1/n)"""
return (Omega**n + N**n)**(1.0/n)
def source_from_triangle(Omega, N, n=n_sharpness):
"""Source (I) as projection: I = Omega^2 / W"""
W = triangle_W(Omega, N, n)
return Omega**2 / W
def source_from_rst(Omega, N, n=n_sharpness):
"""Source (I) from field equation: I = Omega * mu(Omega/N)"""
eta = Omega / N
return Omega * mu_rst(eta, n)
def solve_omega(I, N, n=n_sharpness):
"""Given source I and noise N, solve for Omega."""
def residual(Omega):
return source_from_rst(Omega, N, n) - I
return brentq(residual, 1e-30, 1e15)
```
---
## 4. Proof 1: Identity Closure
```python
def run_proof_1():
test_omegas = np.logspace(-3, 3, 13)
print("PROOF 1: Triangle == Field Equation")
print("=" * 60)
print(f"\n{'Omega':>12} {'I (triangle)':>14} {'I (RST)':>14} {'Match':>6}")
print("-" * 55)
all_match = True
for Om in test_omegas:
I_tri = source_from_triangle(Om, N_FLOOR)
I_rst = source_from_rst(Om, N_FLOOR)
match = np.isclose(I_tri, I_rst, rtol=1e-12)
all_match = all_match and match
print(f"{Om:12.4e} {I_tri:14.8e} {I_rst:14.8e} {'OK' if match else 'FAIL':>6}")
print(f"\nIdentity holds across 6 orders of magnitude: {all_match}")
return all_match
```
---
## 5. Proof 2: Budget Identity
```python
def run_proof_2():
test_omegas = np.logspace(-3, 3, 13)
print("\n" + "=" * 60)
print("PROOF 2: Budget Identity (mu^n + nu^n = 1)")
print("=" * 60)
print(f"\n{'Omega':>12} {'mu':>10} {'nu':>10} {'mu^n+nu^n':>12} {'=1?':>6}")
print("-" * 55)
budget_ok = True
for Om in test_omegas:
W = triangle_W(Om, N_FLOOR)
mu = Om / W
nu = N_FLOOR / W
budget = mu**n_sharpness + nu**n_sharpness
ok = np.isclose(budget, 1.0, rtol=1e-10)
budget_ok = budget_ok and ok
print(f"{Om:12.4e} {mu:10.6f} {nu:10.6f} {budget:12.8f} {'OK' if ok else 'FAIL':>6}")
print(f"\nBudget identity holds: {budget_ok}")
return budget_ok
```
---
## 6. Proof 3: Roundtrip
```python
def run_proof_3():
test_sources = [0.001, 0.01, 0.1, 0.5, 1.0, 5.0, 100.0, 10000.0]
print("\n" + "=" * 60)
print("PROOF 3: Roundtrip (I -> Omega -> I)")
print("=" * 60)
print(f"\n{'I (input)':>12} {'Omega':>12} {'I (recovered)':>14} {'Match':>6}")
print("-" * 50)
roundtrip_ok = True
for I_in in test_sources:
Om = solve_omega(I_in, N_FLOOR)
I_out = source_from_rst(Om, N_FLOOR)
ok = np.isclose(I_in, I_out, rtol=1e-10)
roundtrip_ok = roundtrip_ok and ok
print(f"{I_in:12.4e} {Om:12.6f} {I_out:14.8e} {'OK' if ok else 'FAIL':>6}")
print(f"\nRoundtrip identity holds: {roundtrip_ok}")
return roundtrip_ok
```
---
## 7. Plotting (Four Forces, Budget, Three Regimes)
> **Weak panel (Panel 1):** The theory defines the Weak projection as $\Gamma = I/\tau = \Omega^2/(W\cdot\tau)$. The code plots `refresh = μ²`, i.e. the **dimensionless** part $\mu^2 = \Omega^2/W^2$ (the factor depending on $\Omega$ and $W$ when $\tau$ is fixed). The full $\Gamma$ has dimension 1/time; the plot shows the dimensionless representation of the refresh burden.
```python
def run_plot():
snr = np.logspace(-2, 2, 1000)
Omega = snr * N_FLOOR
W = triangle_W(Omega, N_FLOOR)
mu = Omega / W
nu = N_FLOOR / W
friction = 1.0 - mu
refresh = mu**2 # dimensionless part of Gamma = I/tau; full Gamma = Omega^2/(W*tau)
fig, axes = plt.subplots(2, 3, figsize=(18, 11))
# Panel 1: Four Forces
ax = axes[0, 0]
ax.plot(snr, mu, 'r', lw=2.5, label=r'EM: $\mu = \Omega/W