|
| 1 | +"""Cross-cube interference probe (CANON open item #4, §6.4). |
| 2 | +
|
| 3 | +Characterizes what it means for a nested cube³:0 to interfere with its parent. |
| 4 | +For each parent attractor we spawn its 6 children through the FCAS portal and |
| 5 | +measure, via fcas.cross_cube_interference, two things: |
| 6 | +
|
| 7 | + 1. depth coherence — mean |Pearson(parent, child)| across all parent×face |
| 8 | + pairs. Because expand_cube seeds children with sha256(portal_hash + face), |
| 9 | + children are decorrelated from the parent by construction, so this should |
| 10 | + sit at the noise floor for two independent length-4096 vectors, ≈ 1/√4096 |
| 11 | + ≈ 0.0156. That is the decisive orthogonality test. |
| 12 | + 2. GROUNDED fraction vs the null expectation parent_peak_rate × |
| 13 | + child_peak_rate. Converged attractors are dense (peak almost everywhere), |
| 14 | + so both observed GROUNDED and the null product land near 1.0 — co-peaking |
| 15 | + reflects attractor density, not interference structure, and is *also* |
| 16 | + consistent with independence. |
| 17 | +
|
| 18 | +Conclusion the numbers support: the fractal address space is an orthogonal |
| 19 | +decomposition — a child cannot constructively interfere with its parent. |
| 20 | +
|
| 21 | +Usage |
| 22 | +----- |
| 23 | + python scripts/bench/cross_cube_probe.py |
| 24 | + python scripts/bench/cross_cube_probe.py --json |
| 25 | +""" |
| 26 | + |
| 27 | +from __future__ import annotations |
| 28 | + |
| 29 | +import argparse |
| 30 | +import json |
| 31 | + |
| 32 | +import numpy as np |
| 33 | + |
| 34 | +from wheeler_memory.constants import INTERFERENCE_PEAK_THRESHOLD |
| 35 | +from wheeler_memory.dynamics import evolve_batch |
| 36 | +from wheeler_memory.fcas import cross_cube_interference, evolve_cube, portal_hash |
| 37 | +from wheeler_memory.hashing import hash_to_frame |
| 38 | + |
| 39 | +# Imported read-only — does not modify the sacred benchmark corpus. |
| 40 | +from scripts.bench_quality import TEST_INPUTS |
| 41 | + |
| 42 | + |
| 43 | +def _peak_rate(att: np.ndarray) -> float: |
| 44 | + return float((np.abs(att) > INTERFERENCE_PEAK_THRESHOLD).mean()) |
| 45 | + |
| 46 | + |
| 47 | +def run_probe(verbose: bool = True) -> dict: |
| 48 | + """Aggregate cross-cube interference over the fixed corpus.""" |
| 49 | + parents = [r["attractor"] for r in evolve_batch([hash_to_frame(t) for t in TEST_INPUTS])] |
| 50 | + |
| 51 | + coherences: list[float] = [] |
| 52 | + grounded: list[float] = [] |
| 53 | + signals: list[float] = [] |
| 54 | + parent_peaks: list[float] = [] |
| 55 | + child_peaks: list[float] = [] |
| 56 | + |
| 57 | + for parent in parents: |
| 58 | + reading = cross_cube_interference(parent) |
| 59 | + coherences.extend(f["correlation"] for f in reading["per_face"].values()) |
| 60 | + grounded.append(reading["grounded_fraction"]) |
| 61 | + signals.append(reading["mean_signal_strength"]) |
| 62 | + parent_peaks.append(_peak_rate(parent)) |
| 63 | + for child_result in evolve_cube(portal_hash(parent)).values(): |
| 64 | + child_peaks.append(_peak_rate(child_result["attractor"])) |
| 65 | + |
| 66 | + mean_parent_peak = float(np.mean(parent_peaks)) |
| 67 | + mean_child_peak = float(np.mean(child_peaks)) |
| 68 | + null_grounded = mean_parent_peak * mean_child_peak |
| 69 | + noise_floor = 1.0 / np.sqrt(4096) # expected std of r for independent vectors |
| 70 | + |
| 71 | + return { |
| 72 | + "n_parents": len(parents), |
| 73 | + "n_pairs": len(coherences), |
| 74 | + "mean_abs_correlation": round(float(np.mean(coherences)), 5), |
| 75 | + "max_abs_correlation": round(float(np.max(coherences)), 5), |
| 76 | + "noise_floor": round(float(noise_floor), 5), |
| 77 | + "observed_grounded_fraction": round(float(np.mean(grounded)), 5), |
| 78 | + "null_grounded_fraction": round(null_grounded, 5), |
| 79 | + "mean_parent_peak_rate": round(mean_parent_peak, 5), |
| 80 | + "mean_child_peak_rate": round(mean_child_peak, 5), |
| 81 | + "mean_signal_strength": round(float(np.mean(signals)), 5), |
| 82 | + } |
| 83 | + |
| 84 | + |
| 85 | +def main() -> None: |
| 86 | + parser = argparse.ArgumentParser(description="Cross-cube interference probe (§6.4)") |
| 87 | + parser.add_argument("--json", action="store_true", help="Print JSON only") |
| 88 | + args = parser.parse_args() |
| 89 | + |
| 90 | + if not args.json: |
| 91 | + print( |
| 92 | + f"Cross-cube interference probe " |
| 93 | + f"({len(TEST_INPUTS)} parents × 6 children)...\n" |
| 94 | + ) |
| 95 | + result = run_probe(verbose=not args.json) |
| 96 | + |
| 97 | + if args.json: |
| 98 | + print(json.dumps(result)) |
| 99 | + return |
| 100 | + |
| 101 | + orthogonal = result["mean_abs_correlation"] < 3 * result["noise_floor"] |
| 102 | + grounded_consistent = ( |
| 103 | + abs(result["observed_grounded_fraction"] - result["null_grounded_fraction"]) |
| 104 | + < 0.05 |
| 105 | + ) |
| 106 | + |
| 107 | + print(f"{'=' * 60}") |
| 108 | + print(" CROSS-CUBE INTERFERENCE PROBE") |
| 109 | + print(f"{'=' * 60}") |
| 110 | + print(f" parent×child pairs : {result['n_pairs']}") |
| 111 | + print( |
| 112 | + f" depth coherence (mean |r|): {result['mean_abs_correlation']:.5f} " |
| 113 | + f"(noise floor 1/√4096 = {result['noise_floor']:.5f})" |
| 114 | + ) |
| 115 | + print(f" max |r| : {result['max_abs_correlation']:.5f}") |
| 116 | + print( |
| 117 | + f" GROUNDED observed → null : " |
| 118 | + f"{result['observed_grounded_fraction']:.4f} → {result['null_grounded_fraction']:.4f}" |
| 119 | + f" (peak rates {result['mean_parent_peak_rate']:.3f} / " |
| 120 | + f"{result['mean_child_peak_rate']:.3f})" |
| 121 | + ) |
| 122 | + print(f" mean signal strength : {result['mean_signal_strength']:.5f}") |
| 123 | + print(f"{'-' * 60}") |
| 124 | + verdict = ( |
| 125 | + "ORTHOGONAL — children are independent of parent" |
| 126 | + if orthogonal and grounded_consistent |
| 127 | + else "NON-TRIVIAL interference detected — investigate" |
| 128 | + ) |
| 129 | + print(f" verdict: {verdict}") |
| 130 | + print(f"{'=' * 60}") |
| 131 | + |
| 132 | + |
| 133 | +if __name__ == "__main__": |
| 134 | + main() |
0 commit comments