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>