Relational/Logic Programming in Python?
Solution 1
Perhaps you should google "Logic Programming in Python". Pyke looks promising:
Pyke introduces a form of Logic Programming (inspired by Prolog) to the Python community by providing a knowledge-based inference engine (expert system) written in 100% Python.
Unlike Prolog, Pyke integrates with Python allowing you to invoke Pyke from Python and intermingle Python statements and expressions within your expert system rules.
Solution 2
You may want to use pyDatalog, a logic programming library that I developed for Python implementing Datalog. It also works with SQLAlchemy to query relational databases using logic clauses.
Solution 3
As we are heading toward 2019, I recommend PySWIP over others recommended here. It is actively maintained and has an easy interface, unlike Pyke (9 years ago) or PyLog (6 years ago).
Solution 4
LogPy is an implementation of miniKanren, a relational programming language, in Python. It follows in th tradition of core.logic
, the preeminent logic programming solution in Clojure. LogPy was designed for interoperability with pre-existing codebases.
Solution 5
Another option is Yield Prolog
Comments
-
AJ. almost 2 years
I'm a longtime python developer and recently have been introduced to Prolog. I love the concept of using relationship rules for certain kinds of tasks, and would like to add this to my repertoire.
Are there any good libraries for logic programming in Python? I've done some searching on Google but only found the following:
jtauber's blog series on relational_python
Would love to compare to some others...thanks!
-aj
-
AJ. over 14 years@Richie, looks like a useful package. Thanks for the pointer!
-
heltonbiker about 13 yearsfrom Pyke's page: "Pyke introduces a form of Logic Programming (inspired by Prolog) to the Python community by providing a knowledge-based inference engine (expert system) written in 100% Python."
-
andrew cooke almost 13 yearsis Dee an implementation of D (as described in Date's books?)
-
greg almost 13 yearsIt is (without the object/type specifications)
-
Janus Troelsen over 12 yearstoo bad it seems dead. looked promising
-
andrew cooke about 12 yearsthat's very cool, but does it inter-operate with python? it is written on top of pypy, which also supports (famously) a python implementation, but it's not clear to me that implies inter-op. also, while i am here, blog.herraiz.org/archives/238 is a few years old, but listed various options (it implies pyrolog inter-op, but also sounds like it is simply assumed because of pypy, which is what i am questioning).
-
false about 12 yearsProof-of-concept rather. So going with the soruces might permit that.
-
ThiefMaster over 11 yearsYou need to disclose that it's your project!
-
user48956 over 4 yearsIs it straightfoward to apply tabling in PySWIP (to avoid infinite loops, etc...?), as in pyDatalog.