Adds two new builtins to lib/prolog/runtime.sx:
- sub_atom/5: non-deterministic substring enumeration. Iterates all
(start, length) pairs over the atom string, tries to unify Before,
Length, After, SubAtom for each candidate. Uses CPS loop helpers
pl-substring, pl-sub-atom-try-one!, pl-sub-atom-loop!. Fixed trail
undo semantics: only undo on backtrack (k returns false), not on success.
- aggregate_all/3: collects all solutions via pl-collect-solutions then
reduces. Templates: count, bag(T), sum(E), max(E), min(E), set(T).
max/min fail on empty; count/bag/sum/set always succeed.
New test suite lib/prolog/tests/string_agg.sx: 25 tests, all passing.
Total conformance: 496/496.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- parser.sx: add (":-" 1200 "xfx") to pl-op-table so (head :- body) parses
inside paren expressions (parens reset prec to 1200, allowing xfx match)
- parser.sx: extend pl-token-op to accept "op" token type, not just "atom",
since the tokenizer emits :- as {:type "op" :value ":-"}
- tests/assert_rules.sx: 15 new tests covering assertz/asserta with rule
terms, conjunction in rule body, recursive rules, and ordering
- conformance.sh: wire in assert_rules suite
- 456 → 471 tests, all passing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds 6 new built-in predicates to the Prolog runtime and 24 tests covering
term<->atom conversion (bidirectional), output capture, format directives (~w/~a/~d/~n/~~).
456/456 tests passing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds 5 new built-in predicates to the Prolog runtime with 15 tests.
390 → 405 tests across 20 suites (all passing).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Adds pl-apply-goal helper for safe call/N goal construction (atom or compound),
five solver helpers (pl-solve-forall!, pl-solve-maplist2!, pl-solve-maplist3!,
pl-solve-include!, pl-solve-exclude!), five cond clauses in pl-solve!, and a
new test suite (15/15 passing). Total conformance: 390/390.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>