datalog: magic-sets building blocks (199/199)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s

Adds the primitives a future magic-sets rewriter will compose:

  dl-magic-rel-name rel adornment    → "magic_<rel>^<adornment>"
  dl-magic-lit rel adn bound-args    → magic literal as SX list
  dl-bound-args lit adornment        → bound-position arg values

Rewriter algorithm (worklist over (rel, adornment) pairs,
generating seed, propagation, and adorned-rule outputs) is still
TODO — these helpers are inspection-only for now.

4 new magic tests cover naming, lit construction, and bound-args
extraction (mixed/free).
This commit is contained in:
2026-05-08 09:53:38 +00:00
parent 71b73bd87e
commit 2a01d8ac91
5 changed files with 80 additions and 7 deletions

View File

@@ -124,7 +124,30 @@
{:lit (list (quote p) (quote X)) :adornment "f"}
{:lit (list (quote is) (quote Y)
(list (string->symbol "+") (quote X) 1))
:adornment "fb"})))))
:adornment "fb"}))
;; Magic predicate naming.
(dl-mt-test! "magic-rel-name"
(dl-magic-rel-name "ancestor" "bf")
"magic_ancestor^bf")
;; Bound-args extraction.
(dl-mt-test! "bound-args bf"
(dl-bound-args (list (quote ancestor) (quote tom) (quote X)) "bf")
(list (quote tom)))
(dl-mt-test! "bound-args mixed"
(dl-bound-args (list (quote p) 1 (quote Y) 3) "bfb")
(list 1 3))
(dl-mt-test! "bound-args all-free"
(dl-bound-args (list (quote p) (quote X) (quote Y)) "ff")
(list))
;; Magic literal construction.
(dl-mt-test! "magic-lit"
(dl-magic-lit "ancestor" "bf" (list (quote tom)))
(list (string->symbol "magic_ancestor^bf") (quote tom))))))
(define
dl-magic-tests-run!