Files
rose-ash/lib/minikanren
giles 1d7400a54a
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 49s
mk: phase 7 piece A — SLG-style tabling with in-progress sentinel
Solves the canonical cyclic-graph divergence problem from the deferred
plan. Naive memoization (table-1/2/3 in tabling.sx) drains the body's
answer stream eagerly; cyclic recursive calls with the same ground key
diverge before populating the cache.

table-2-slg / table-3-slg add an in-progress sentinel: before
evaluating the body, mark the cache entry :in-progress. Any recursive
call to the same key sees the sentinel and returns mzero (no answers
yet). Outer recursion thus terminates on cycles. After the body
finishes, the sentinel is replaced with the actual answer-value list.

Demo: tab-patho with a 3-edge graph (a -> b, b -> a, b -> c).
  (run* q (tab-patho :a :c q))   -> ((:a :b :c))   ; finite
  (run* q (tab-patho :a :a q))   -> ((:a :b :a))   ; one cycle visit
  (run* q (tab-patho :a :b q))   -> ((:a :b))      ; direct edge

Without SLG, all three diverge.

Limitation: single-pass — answers found by cycle-dependent recursive
calls are not iteratively re-discovered. Full SLG with fixed-point
iteration (re-running until no new answers) is left for follow-up.

5 new tests including SLG-fib for sanity (matches naive table-2),
3 cyclic patho cases.
2026-05-09 14:10:43 +00:00
..
2026-05-08 10:41:02 +00:00