datalog: dl-query accepts conjunctive goal lists (167/167)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 54s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 54s
dl-query now auto-dispatches on the first element's shape:
- positive literal (head is a symbol) or {:neg ...} dict → wrap
- list of literals → conjunctive query
dl-query-coerce normalizes; dl-query-user-vars collects the union
of user-named vars (deduped, '_' filtered) for projection. Old
single-literal callers unchanged.
(dl-query db '(p X)) ; single
(dl-query db '((p X) (q X))) ; conjunction
(dl-query db (list '(n X) '(> X 2))) ; with comparison
2 new api tests cover multi-goal AND and conjunction with comparison.
This commit is contained in:
@@ -222,7 +222,11 @@ large graphs.
|
||||
```
|
||||
- [x] `(dl-rule head body)` constructor for the dict form.
|
||||
- [x] `(dl-query db '(ancestor tom X))` already worked — same query API
|
||||
consumes the SX-data goal.
|
||||
consumes the SX-data goal. Now also accepts a *list* of body
|
||||
literals for conjunctive queries:
|
||||
`(dl-query db '((p X) (q X)))`,
|
||||
`(dl-query db (list '(n X) '(> X 2)))`. Auto-dispatched via
|
||||
`dl-query-coerce` on first-element shape.
|
||||
- [x] `(dl-assert! db '(parent ann pat))` → adds the fact and re-saturates.
|
||||
- [x] `(dl-retract! db '(parent bob ann))` → drops matching tuples from
|
||||
the EDB list, wipes every relation that has a rule (those are IDB),
|
||||
@@ -273,6 +277,14 @@ large graphs.
|
||||
|
||||
_Newest first._
|
||||
|
||||
- 2026-05-08 — `dl-query` accepts a list of body literals for
|
||||
conjunctive queries, in addition to a single positive literal.
|
||||
`dl-query-coerce` dispatches based on the first element's shape:
|
||||
positive lit (head is a symbol) or `:neg` dict → wrap as singleton;
|
||||
list of lits → use as-is. `dl-query-user-vars` collects the union
|
||||
of vars across all goals (deduped, `_` filtered) for projection.
|
||||
2 new api tests: multi-goal AND, and conjunction with comparison.
|
||||
|
||||
- 2026-05-08 — Bug fix: `dl-check-stratifiable` now rejects recursion
|
||||
through aggregation (e.g., `q(N) :- count(N, X, q(X))`). The
|
||||
stratifier was already adding negation-like edges for aggregates,
|
||||
|
||||
Reference in New Issue
Block a user