datalog: bipartite friends-with-hobby join test (229/229)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 48s

This commit is contained in:
2026-05-08 12:39:04 +00:00
parent 8e508bc90f
commit 9edccb8f33
3 changed files with 18 additions and 6 deletions

View File

@@ -273,6 +273,18 @@
(dl-saturated? db))
false)
;; Bipartite-style join: pair-of-friends who share a hobby.
;; Three-relation join exercising the planner's join order.
(dl-et-test-set! "bipartite friends-with-hobby"
(dl-query
(dl-program
"hobby(alice, climb). hobby(bob, paint).
hobby(carol, climb).
friend(alice, carol). friend(bob, alice).
match(A, B, H) :- friend(A, B), hobby(A, H), hobby(B, H).")
(list (quote match) (quote A) (quote B) (quote H)))
(list {:A (quote alice) :B (quote carol) :H (quote climb)}))
;; Repeated variable (diagonal): p(X, X) only matches tuples
;; whose two args are equal. The unifier handles this via the
;; subst chain — first occurrence binds X, second occurrence