Commit Graph

5 Commits

Author SHA1 Message Date
917ffe5ccc datalog: comparison ops require same-type operands
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 28s
Type-mixed comparisons were silently inconsistent:

  <("hello", 5)  =>  no result, no error  (silent false)
  <(a, 5)        =>  raises "Expected number, got symbol"

Both should fail loudly with a comprehensible message. Added
dl-compare-typeok?: <, <=, >, >= now require both operands to share
a primitive type (both numbers or both strings) and raise a clear
"comparison <op> requires same-type operands" error otherwise.

`!=` is exempted because it's the polymorphic inequality test
built on dl-tuple-equal? — cross-type pairs are legitimately unequal
and the existing semantics for that case match user intuition.

2 new regression tests; conformance 267/267.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 08:07:40 +00:00
00881f84eb datalog: arith / by zero raises instead of returning inf
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 47s
`is(R, /(X, 0))` was silently producing IEEE infinity:

  (dl-eval "p(10). q(R) :- p(X), is(R, /(X, 0))." "?- q(R).")
  => ({:R inf})

That value then flowed through comparisons (anything < inf, anything
> inf) and aggregations (sum of inf, max of inf) producing nonsense
results downstream. `dl-eval-arith` now checks the divisor before
the host `/` and raises "division by zero in <expr>" — surfacing
the bug at its source rather than letting infinity propagate.

1 new test; conformance 264/264.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 07:59:25 +00:00
4a7cff2f6b datalog: built-in-only query goals (236/236)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 47s
2026-05-08 14:19:25 +00:00
ec7e4dd5c4 datalog: bounded-successor regression test (224/224)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
2026-05-08 10:36:13 +00:00
7ce723f732 datalog: built-ins + body arithmetic + order-aware safety (Phase 4, 106/106)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 50s
New lib/datalog/builtins.sx: (< <= > >= = !=) and (is X expr) with
+ - * /. dl-eval-arith recursively evaluates nested compounds.
Safety analysis now walks body left-to-right tracking the bound
set: comparisons require all args bound, is RHS vars must be bound
(LHS becomes bound), = special-cases the var/non-var combos.
db.sx keeps the simple safety check as a forward-reference
fallback; builtins.sx redefines dl-rule-check-safety to the
comprehensive version. eval.sx dispatches built-ins through
dl-eval-builtin instead of erroring. 19 new tests.
2026-05-07 23:51:21 +00:00