Logic programming in Python
from pyDatalog import pyDatalog pyDatalog.create_terms('factorial, N')
factorial[N] = N*factorial[N-1]
factorial[1] = 1
print(factorial[3]==N) # prints N=6
pyDatalog adds the logic programming paradigm to Python's extensive toolbox, in a pythonic way.
Logic programmers can now use the extensive standard library of Python, and Python programmers can now express complex algorithms quickly.
Datalog is a truly declarative language derived from Prolog, with strong academic foundations. Datalog excels at managing complexity. Datalog programs are shorter than their Python equivalent, and Datalog statements can be specified in any order, as simply as formula in a spreadsheet.
pyDatalog can be used for:
pyDatalog is derived from previous work by John D. Ramsdell. It is an open-source project (LGPL) lead by Pierre Carbonnelle (in Belgium). It is inspired by LogicBlox.
pyDatalog embeds logic programming in Python :
More specifically:
len_, sum_, concat_, min_, max_, tuple_, rank_, running_sum_, mean_, linear_regression
p[X]==Y
) , i.e. logic predicate with unicityEmployee.name[X]==Y
): their first argument refers to instances of the class.(X == Y+1)
. An expression can contain Python functions and lambda expressionsp(X)
pyDatalog is a fast and lightweight datalog interpreter written in Python:
The depth of recursion is not limited by the stack size.
pyDatalog has been tested with python 2.7, 3.3, 3.4, pypy 1.9 - 2.0, and SQLAlchemy 0.7 - 0.9, on Windows. (over 400 tests)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4