I’m trying out tabling, but I get an unintelligible error:
ERROR: -g main: No permission to append findall-bag `[...]' (continuation in findall/3 generator?)
ERROR: In:
ERROR: [13] throw(error(permission_error(append,'findall-bag',...),context(...,'continuation in findall/3 generator?')))
ERROR: [12] '$tabling':start_tabling(user:auswerten(jm,_2980),user:'auswerten tabled'(jm,_2992)) at /usr/lib/swi-prolog/boot/tabling.pl:98
ERROR: [10] auswerten1(jm,_3018) at /home/v/src/tt/tt2.pl:207
ERROR: [9] main at /home/v/src/tt/tt2.pl:80
ERROR: [8] catch(user:main,error(permission_error(append,'findall-bag',...),context(...,'continuation in findall/3 generator?')),'$toplevel':true) at /usr/lib/swi-prolog/boot/init.pl:386
ERROR: [7] catch_with_backtrace(user:main,error(permission_error(append,'findall-bag',...),context(...,'continuation in findall/3 generator?')),'$toplevel':true) at /usr/lib/swi-prolog/boot/init.pl:436
ERROR:
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
I’ve no idea what that means. Does someone have a hint?
That is a complicated way to tell that you have a recursive tabled loop through findall/3. That is not possible.
Well, maybe it is different. If you are on 8.0.x tabling and findall do not combine at all. Using a not-too-old 8.1.x tabling and findall/3 work fine, provided that the goal called by findall does not (indirectly) call any tabled variant that calls the findall/3.
Tabling is (by default) based on variants (see =@=/2). The problem arises when variant V calls findall/3, which in turn calls V. For example:
p(X,Y) :-
findall(Z, p(X,Z), Zs).
If we call this is p(1, X), the findall/3 goal is p(1,Z) and as X and Z are unbound, this is a variant. Now we get a child call of findall/3 being dependent on a caller of findall/3. That leads to this error.
I’ve rearranged my program, and now it works. I’m building a sort of miniature expert system, and am using tabling to accomplish termination. Thanks for your help!