4 ms·
I interviewed and helped hire Mark Thom, the original author of Scryer. I also follow Scryer with interest, even though most of my limited Prolog use has been w
by mark_l_watson 2y ago
I interviewed and helped hire Mark Thom, the original author of Scryer. I also follow Scryer with interest, even though most of my limited Prolog use has been with SWI Prolog (and one large project with ExperProlog in the 1980s).
One thing to check out: Prolog plays fairly well with Python, providing opportunities for hybrid projects.
- klibertp 2y agoTo playing well with Python, this was on a front page some time ago: https://arxiv.org/abs/2308.15893 https://arxiv.org/abs/2308.15893 "The Janus System: Multi-paradigm Programming in Prolog and Python"
- mark_l_watson 2y agoHey, thanks! That looks cool.
- philzook 2y agoI am quite pleased with the ability to easily use prolog from within python and vice versa. It makes it now one of the easiest and most expressive solvers to plug into for my tastes. I'm starting to accumulate useful solvers here https://github.com/philzook58/prologsolvers/tree/164297d87f67202e5906d03a5b07d6ff7ce75ef9 https://github.com/philzook58/prologsolvers/tree/164297d87f6... You need to install swi prolog https://www.swi-prolog.org/download/stable https://www.swi-prolog.org/download/stable and pip install janus_swi A simple example to get started: https://www.swi-prolog.org/pldoc/doc_for?object=section(%27packages/janus.html%27) https://www.swi-prolog.org/pldoc/doc_for?object=section(%27p... import janus_swi as janus janus.consult("path", """ edge(a,b). edge(b,c). edge(c,d). :- table path/2. path(X,Y) :- edge(X,Y). path(X,Y) :- edge(X,Z), path(Z,Y). """) list(janus.query("path(a,Y)."))
- nextos 2y agoOn the topic of multi-paradigm programming, including logic programming, Oz/Mozart is an obligatory mention. See CTM and http://mozart2.org/mozart-v1/doc-1.4.0/tutorial/index.html http://mozart2.org/mozart-v1/doc-1.4.0/tutorial/index.html. The authors were fairly prominent Prolog researchers. It's sad Van Roy is retiring and nobody is taking this forward. AliceML, a StandardML dialect inspired by Oz is also abandonware.
- nerdponx 2y agoHow do you normally use Prolog and Python together? I had looked into embedding logic programming within Python in the past, and found a lack of satisfying options, but maybe I didn't know where to look.
- mark_l_watson 2y agoI have two short examples in one of my books that I am currently re-writing. Here is a link directly to the Python+ Prolog interop examples https://leanpub.com/pythonai/read#use-predicate-logic-by-calling-swi-prolog https://leanpub.com/pythonai/read#use-predicate-logic-by-cal...
- networked 2y agoThanks for the link. I have played with PySwip (https://github.com/yuce/pyswip https://github.com/yuce/pyswip), and the MQI looks like a more maintainable approach to integrating SWI-Prolog with Python (https://github.com/SWI-Prolog/packages-mqi https://github.com/SWI-Prolog/packages-mqi). The biggest source of friction I noticed when playing with PySwip was that because Prolog code was represented as strings, you avoided generating it on the fly. It would be nice to have an embedded DSL for Prolog in Python. (I am thinking something like SymPy or the Pony ORM—https://github.com/ponyorm/pony https://github.com/ponyorm/pony.)
- nickswalker 2y agoI noticed the same friction while trying to integrate Answer Set Programming solvers into Python projects. The people who built the dominant ASP solver actually provide nice solutions though. Possible inspiration for Prolog tooling: Clorm (Clingo ORM) [1] makes it easy to create facts after you define simple predicate Python classes. Here's an example project of mine which uses it to set up a scheduling problem (Python -> ASP) and to present the results (ASP -> Python). https://github.com/raceconditionrunning/relay-scheduler https://github.com/raceconditionrunning/relay-scheduler Clingo (the solver) exposes its internal AST implementation through Python bindings[2], so you can build up rules or other statements from typed components instead of strings. This simplifies the translation bits of implementing an ORM or whatever kind of wrapper a developer would prefer. [1] https://github.com/potassco/clorm https://github.com/potassco/clorm [2] https://potassco.org/clingo/python-api/current/clingo/ast.html https://potassco.org/clingo/python-api/current/clingo/ast.ht...