Python 中的关系/逻辑编程?
我是一名长期的 Python 开发人员,最近接触了 Prolog。我喜欢在某些类型的任务中使用关系规则的概念,并且想将其添加到我的技能中。
Python 有什么好的逻辑编程库吗?我在 Google 上进行了一些搜索,但只找到了以下内容:
jtauber's blog series onoretal_python
很想与其他一些...谢谢!
-aj
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
您可能需要使用 pyDatalog,这是我为实现 数据日志。它还与 SQLAlchemy 配合使用逻辑子句查询关系数据库。
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.
也许你应该谷歌搜索“Python 逻辑编程”。 Pyke 看起来很有希望:
Perhaps you should google "Logic Programming in Python". Pyke looks promising:
在我们即将迈向 2019 年之际,我推荐 PySWIP,而不是此处推荐的其他工具。与 Pyke(9 年前)或 PyLog(6 年前)不同,它得到积极维护并具有简单的界面。
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).
LogPy 是 miniKanren,一种关系型编程语言,Python 语言。它遵循卓越的逻辑编程
core.logic
的传统Clojure 中的解决方案。 LogPy 旨在与预先存在的代码库进行互操作。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.另一个选项是 Yield Prolog
Another option is Yield Prolog
您还可以查看 Dee,它添加了与 Python 的关系:http://www.quicksort.co.uk
You could also look at Dee, which adds relations to Python: http://www.quicksort.co.uk
最近在 Python(或者更确切地说 RPython)中实现的 Prolog
Pyrolog。它仍然是相当实验性的。
A recent Prolog implementation in Python (or rather RPython) in
Pyrolog. It is still rather experimental.
您还应该检查 PyLog:
http://cdsoft.fr/pylog/
它有一个非常干净和简单的语法和实施。
You should also check PyLog:
http://cdsoft.fr/pylog/
It has a very clean and simple syntax and implementation.
你可以看看pytholog。
它完全是用 python 编写的,没有与 prolog 的接口,它模仿了 prolog 的语法、方法和回溯。
只需启动一个知识库并为其提供事实和规则,然后运行查询即可。
它还支持计算和概率
它还可以用于查找图中节点之间的路径。
You can have a look at pytholog.
It is written in python totally with no interfaces with prolog and it mimics prolog's syntax, approach and backtracking.
Simply initiate a KnowledgeBase and feed it with facts and rules then run queries.
It also supports calculations and probabilities
It can also be used to find a path between nodes in graphs.
另一种选择是使用内存关系数据库。毕竟SQL是最流行的关系语言,它和Prolog有很多相似之处。
pandas (与 SQL 比较)
SQLite3< /p>
Another option is to use in-memory relational databases. After all, SQL is the most popular relational language, and it has a lot of similarity with Prolog.
pandas (comparison with SQL)
SQLite3