Dynamic subsumptive table/1 predicate

I’ve tried with/without subsumption, it doesn’t make much difference either way.

I have found some oddities with tabling, however:

  1. To speed up table population I use concurrent/1 and once/1 to do so in parallel. In the case of one predicate it appears to table fine, but when the predicate is used the first time it appears the tabling is redone as there’s a significant delay, then subsequent calls are speedy.

  2. In the case of another predicate, it works fine in interpreted mode but if I compile and run I get a determinism failure - the predicate is flagged as det/1 and works perfectly in compiled mode. Scattering cuts about doesn’t help, removing the det/1 does but then I get a determinism failure elsewhere, and:

Time: Fri Jan 23 15:26:55 2026
Inferences: 133469124
Thread: 1 (main)
C-stack trace labeled "crash":
  [0] save_backtrace() at /data2/tmp/swipl-devel-10.1.1/src/os/pl-cstack.c:334 [0x7fa1114baeb8]
  [1] sigCrashHandler() at /data2/tmp/swipl-devel-10.1.1/src/os/pl-cstack.c:845 [0x7fa11144fb0d]
  [2] __restore_rt() at libc_sigaction.c:? [0x7fa1111d2df0]
  [3] localDefinition___LD() at /data2/tmp/swipl-devel-10.1.1/src/pl-wam.c:1609 [0x7fa111461e38]
  [4] assert_term___LD() at /data2/tmp/swipl-devel-10.1.1/src/pl-comp.c:4390 [0x7fa11146a107]
  [5] PL_next_solution_guarded___LD() at /data2/tmp/swipl-devel-10.1.1/src/pl-vmi.c:4343 [0x7fa111459fd1]
  [6] PL_next_solution___LD() at /data2/tmp/swipl-devel-10.1.1/src/pl-wam.c:3574 [0x7fa111459576]
  [7] query_loop() at /data2/tmp/swipl-devel-10.1.1/src/pl-pro.c:171 [0x7fa11149efa3]
  [8] prologToplevel() at /data2/tmp/swipl-devel-10.1.1/src/pl-pro.c:662 [0x7fa11149ee3d]
  [9] PL_toplevel() at /data2/tmp/swipl-devel-10.1.1/src/pl-fli.c:4991 [0x7fa1114b37ca]
  [10] ??? [0x5629959900c0]
  [11] __libc_start_call_main() at ./csu/../sysdeps/nptl/libc_start_call_main.h:74 [0x7fa1111bcca8]
  [12] call_init() at ./csu/../csu/libc-start.c:128 [0x7fa1111bcd65]
  [13] ??? [0x562995990101]


PROLOG STACK (without arguments):
  [2109] system:assertz/1 <foreign>
  [2107] apply:maplist_/2 [PC=8 in clause 2]
  [12] apply:maplist_/2 [PC=8 in clause 2]
Segmentation fault

To emphasise, the code works fine in interpreted mode and only fails when compiled.