Howdy all,
I'm using tabling in my Prolog program, and when calling a tabled predicate, I would like to determine whether the call I'm about to make has been tabled already or not. Is there a way to query the predicate's table before (or after) making the call so I can determine whether the call will succeed via a tabled answer or because the predicate itself was executed?
My situation is more complex than this example, but it will suffice to describe the behavior I would like:
:- table fib/2.
fib(1, 1) :- write('Base case'), nl.
fib(X, Y) :- X1 is X - 1, X2 is X - 2, fib(X1, Y1), fib(X2, Y2), Y is Y1 + Y2, write('Inductive case'), nl.
call_fib(X, Y) :- fib(X, Y), (was_tabled(fib(X, Y)) -> write('Tabled success'), nl ; true /* do nothing */).
Regardless of whether fib is actually executed, I still need to execute the call to write, so I would like a way to determine whether a call succeeds / succeeded because it was already in the table or because the predicate was actually executed.
I do realize that the general principle is "actions taken inside tabled predicates can't be expected to always be executed, so actions that must always be taken should not be placed in tabled predicates." Unfortunately, in my case, the required actions are essentially (non-I/O) data processing instructions that cannot be removed from the tabled predicate but nevertheless must be executed every time the tabled predicate is called, regardless of whether it succeeds or not.
Is there a way to do this?
Thanks,
~Brian W. DeVries
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H_______________________________________________
Yap-users mailing list
Yap-users@...
https://lists.sourceforge.net/lists/listinfo/yap-users