relations: tree/DAG queries (common-ancestors, lca, topo-order) in SX + 16 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s
lib/relations/tree.sx over reach/ancestors/rnode — no new Datalog closures. 126/126. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -18,7 +18,7 @@ links. Reuses `lib/datalog/` — does not reimplement the engine.
|
||||
|
||||
## Status (rolling)
|
||||
|
||||
`bash lib/relations/conformance.sh` → **110/110** (Phases 1–4 complete + extensions)
|
||||
`bash lib/relations/conformance.sh` → **126/126** (Phases 1–4 complete + extensions)
|
||||
|
||||
## Ground rules
|
||||
|
||||
@@ -104,9 +104,23 @@ lib/relations/federation.sx
|
||||
`in-degree`, weakly-connected `connected?` (undirected reachability). Computed in
|
||||
SX over the fast direct `erel` queries (BFS) — deliberately NOT added as Datalog
|
||||
closures, to keep the per-query saturation cheap. `lib/relations/tests/shape.sx`.
|
||||
- [x] **tree/DAG queries** — `common-ancestors` (ancestor-set intersection), `lca`
|
||||
(lowest common ancestors — a set; tree → singleton, DAG → may be several),
|
||||
`topo-order` (Kahn-style; nil for cyclic kinds). New `lib/relations/tree.sx`,
|
||||
computed in SX over `reach`/`ancestors`/`rnode`. `lib/relations/tests/tree.sx`.
|
||||
|
||||
## Progress log
|
||||
|
||||
- **Extension: tree/DAG queries** (126/126). New `lib/relations/tree.sx`:
|
||||
`relations-common-ancestors` (intersection of the two ancestor sets),
|
||||
`relations-lca` (common ancestors with no other common ancestor reachable below
|
||||
them — a SET, since a DAG can have several lowest common ancestors; a tree gives
|
||||
one), `relations-topo-order` (Kahn-style level-by-level: place every node whose
|
||||
parents are all placed; nil for a cyclic kind) + `relations-nodes` (the `rnode`
|
||||
set) and `relations/...` wrappers. All in SX over the engine's fast queries —
|
||||
again no new Datalog closures. `tree.sx` (16 tests) covers diamond common
|
||||
ancestors, LCA on tree vs converging-DAG, no-common-ancestor, topo validity
|
||||
(parents precede children), and cyclic-kind → nil.
|
||||
- **Extension: shape queries** (110/110). Added `relations-siblings`,
|
||||
`relations-out-degree`/`-in-degree`, `relations-connected?` (+ `relations/...`
|
||||
current-db wrappers) and `shape.sx` (18 tests). Design note: an earlier attempt
|
||||
|
||||
Reference in New Issue
Block a user