Python interface with SWI-Prolog

Mythio picture Mythio · Jun 26, 2013 · Viewed 7.2k times · Source

I want to use a Python script as a frontend to a Prolog program that uses the SWI-PL engine.

So, the components of the setup are:

I've been looking around for an interface between SWI-PL and Python. What I found are:

PySwip but it seems to be lacking from what i see from old questions here, and also seems unsupported.

PyLog, which seems newer but also has some activity. Although i don't know how good it is.

What is the recommended way of using Python to communicate with SWI-prolog? Are there perhaps other ways to accomplish this? Maybe with another prolog engine?

I'm stuck with the Prolog language and Python because I know them best, so that would be necessary (I know for instance there are also tools for Java).

Answer

2rs2ts picture 2rs2ts · Jun 26, 2013

I've personally used PySWIP successfully. Here's a link to a project I did for my AI class in university in which I used PySWIP.

I think the difference is that PySWIP is a bridge (just send queries to a Prolog database and get responses) whereas PyLog seems to be an implementation of Prolog (or a built-in Prolog engine) in Python, with abstractions on Prolog code using objects.

I have no particular recommendation for you. Choose whichever you deem will suit your project best. Consider the licenses under which these libraries are published if you will need to worry about your code's license.