Feature Request: Add Tabling to Prevent Infinite Loops #139
Replies: 10 comments
-
Nice indeed and is now done in |
Beta Was this translation helpful? Give feedback.
-
I didn’t expect it to be implemented so quickly, Thank you for your hard work! But I found the test case below is not worked as expected, and gave me stack_overflow error in eye:
Nearly identical code in swi-prolog, using tabling, worked as expected: :- table has/2.
:- table has_instance/2.
has(X, Y) :- has_instance(X, Y).
has_instance(X, Y) :- class(X), has(X, Y).
has(a, b).
class(a).
has_instance(a, c). I also tried |
Beta Was this translation helpful? Give feedback.
-
The point is that |
Beta Was this translation helpful? Give feedback.
-
I’ve found a strange bug, the following test fails to pass:
|
Beta Was this translation helpful? Give feedback.
-
Very strange indeed and I couldn't understand it. |
Beta Was this translation helpful? Give feedback.
-
I’ve run into a problem again. I have observed that
|
Beta Was this translation helpful? Give feedback.
-
With
|
Beta Was this translation helpful? Give feedback.
-
Appreciate!
|
Beta Was this translation helpful? Give feedback.
-
This is strange: we assert |
Beta Was this translation helpful? Give feedback.
-
So 3 issues with tabling in 1 day: 1/ https://github.com/orgs/eyereasoner/discussions/139#discussioncomment-12310146 with a rather ugly work-around
|
Beta Was this translation helpful? Give feedback.
-
Could we implement a tabling mechanism similar to SWI-Prolog's in N3, allowing predicates to be marked as tabled to prevent infinite recursion and enable memoization?
In Prolog, we use the table/1 directive to achieve this property. I'd like similar functionality in N3/eye reasoner for backward-chained predicates.
For example:
Currently, for certain properties, even though there are intuitive ways to express them, I’m forced to use tricky workarounds to avoid loops. One such workaround involves renaming the property to create a dummy version:
Alternatively, I might convert some predicates to forward chaining.
However, for larger programs, circular references are not always this straightforward—they could involve complex loops, And the above workarounds are not always useful. Furthermore, when using terms defined via backward chaining, the interactions between terms often cause problems in unexpected places, making debugging especially difficult.
In addition, (while not as critical as the above) memoization is also incredibly useful for tasks like recursively calculating Fibonacci numbers.
Therefore, having a built-in mechanism, such as
[] e:table :succ
, to mark predicates as tabled, would be extremely helpful.Beta Was this translation helpful? Give feedback.
All reactions