pyDatalog is a tool for "logic programming in Python" (*).
I installed and tried it out with this small program, a modified version of the one on the pyDatalog home page. That program calculates factorials; I added calculation of squares.
Here is the program, test_pydatalog.py:
from pyDatalog import pyDatalog pyDatalog.create_terms('factorial, N') factorial[N] = N*factorial[N-1] factorial = 1 print(factorial==N) print(factorial==N) print(factorial==N) pyDatalog.create_terms('square, N') square[N] = N*N print(square==N) print(square==N) print(square==N)
Run the program with the command:
That gives the following output:
pyDatalog version 0.14.0 N - 2 N - 6 N -- 24 N - 9 N -- 16 N -- 25
I've only tried out pyDatalog out a little so far. Will try it out more later and may post again about it.
Interesting concept. pyDatalog seems to be inspired by either Datalog or LogicBlox.
Datalog in turn is a subset of Prolog, one of oldest logic programming languages.
- Vasudev Ram - Dancing Bison Enterprises