Does pySwip support tabling?

47 views
Skip to first unread message

Jackson Feng

unread,
Mar 10, 2020, 8:12:42 PM3/10/20
to pyswip
I ran the following script in python3.7

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.
Reply all
Reply to author
Forward
0 new messages