In [1]: from pyswip import Prolog
In [2]: prolog = Prolog()
In [3]: prolog.assertz(":- table fib/2")
In [4]: prolog.assertz("fib(0, 1)")
In [5]: prolog.assertz("fib(1, 1)")
In [6]: prolog.assertz("fib(N, F) :- N > 1, N1 is N-1, N2 is N-2, fib(N1, F1), fib(N2, F2), F is F1+F2")
In [7]: for soln in prolog.query("fib(27, X)"):
...: print("------soln---", soln["X"])
There are no errors reported. However, the speed is the same as not using the tabling. Maybe there is another way to set up the tabling? Please let me know. TIA.