Files
rose-ash/lib
giles adc8467c78
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 58s
mk: phase 7 — naive ground-arg tabling, Fibonacci canary green
`table-2` wraps a 2-arg (input, output) relation. On a ground input
walk, looks up the (string-encoded) cache key; on miss, runs the
relation, drains the answer stream, extracts walk*-output values from
each subst, stores them, and replays. On hit, replays the cached
values directly — no recomputation.

Cache lifetime: a single global mk-tab-cache (mutated via set!).
mk-tab-clear! resets between independent queries.

Canonical demo: tabled fib(25) = 75025 in ~5 seconds; the same naive
fib-o times out at 60s. Memoization collapses the exponential redundant
recomputation in the binary recursion.

Limitations (deferred to future SLG work): cyclic recursive calls with
the same ground key still diverge — naive memoization populates the
cache only AFTER computation completes, so a recursive call inside its
own computation can't see the in-progress entry. The brief's "tabled
patho on cyclic graphs" use case requires producer/consumer
scheduling and is left for a future iteration.

12 new tests, fib(0..20) + ground-term predicate + cache-replay
verification. 638/638 cumulative.
2026-05-08 22:27:10 +00:00
..