Skip to content

Commit aa4bd51

Browse files
committed
Experiment 9: phi.fold substrate alignment, re-investigated
Re-frames the question per user direction: log_phi_pi_fibonacci is the substrate's ALIGNMENT measure, not its speed measure. The win isn't fewer compares than binary, it's substrate self-consistency — does the search trajectory describe itself in the substrate's native vocabulary (Fibonacci-step intervals) or in foreign vocabulary (arbitrary halvings). Current state of phi.fold (verified by inspection): interpreter.rs:4980 fold_to_fibonacci_const(n) fibs: [i64; 15] = [0, 1, 2, ..., 610]; for &f in &fibs { ... linear scan ... } value.rs:33 HInt::compute_resonance — same pattern, 16-element array. Every HInt::new(), every res(x), every phi.fold(x), every harmonic_sort, every healer attractor check pays a linear scan over a DUPLICATED Fibonacci table. The foundational operation is implemented OUTSIDE the substrate's own algorithm. Headline measurements (200 random queries on [0, 700]): linear scan: 3000 compares total (15/query, deterministic). Step coherence trivially 1.0 (step always = F_1). binary search: 792 compares total (3.96/query). Step coherence 392/592 = 0.66 — step sizes include 4 and 7 which aren't Fibonacci. phi_pi_fib: 1116 compares total (5.58/query). Step coherence not externally measurable (builtin doesn't expose its probe trace); analytically ~1.0 by construction since the algorithm probes at F(k) offsets. Scaling check (200-entry attractor table): linear: 40,000 compares — quadratic blowup. binary: 1,549 compares. phi_pi_fib: 2,039 compares. Honest finding: - Linear scan is the wasteful choice. phi.fold should NOT be doing a 15-compare scan per call when a 4-6 compare search suffices. - Binary search is faster in raw compares (consistent with exp 8). - phi_pi_fib is the substrate-coherent choice: step sizes are F(k) by construction, so the trajectory speaks the substrate's vocabulary. Binary's halving steps don't. - The measurement gap (coherence of the builtin) is real and flagged in the file — fixing it needs a traced variant of the builtin, or an OMC-level port of the search. Refactor proposal (Phase 2 of substrate unification, pending review): 1. Promote phi_pi_fib::FIBONACCI to canonical table (delete 17 dupes). 2. Rewrite fold_to_fibonacci_const(n) and HInt::compute_resonance to call phi_pi_fib_nearest on the canonical table. 3. Conformance tests (res(89)==1.0 etc.) stay byte-identical because both algorithms find the same nearest attractor. Both engines audit byte-identical (3569 bytes). 148/148 tests pass.
1 parent 897a3ec commit aa4bd51

1 file changed

Lines changed: 401 additions & 0 deletions

File tree

0 commit comments

Comments
 (0)