Skip to content

Latest commit

 

History

History
executable file
·
30 lines (21 loc) · 1.13 KB

README.md

File metadata and controls

executable file
·
30 lines (21 loc) · 1.13 KB

swipl-server

  • A script for SWI-Prolog that runs a server listening for requests to execute assertions and queries.
  • A client module for Python to issue Prolog assertions & queries.

You must install the latest development version of SWI-Prolog (it needs to have the serialize_unknown option available for json_write.)

Usage:

from swiplclient import Prolog

PL_HOST = "localhost"
PL_PORT = 5000
PL_PASSWORD = "xyzzy"

prolog = Prolog(PL_HOST, PL_PORT, PL_PASSWORD)

# Sample assertions and query:

prolog.add("father(jack, john)")
prolog.add("brothers(joey, jack)")
prolog.add("brothers(A,B) :- "
                        "B @< A, brothers(B,A)") # Make brothers/2 symmetric
prolog.add("uncle(X,Y) :- brothers(Z,X), father(Z,Y)")
print prolog.query("uncle(Uncle,Nephew)")

DISCLAIMER:

This code is provided as-is. Be aware that this SWI-Prolog script runs a server that listens for and executes queries, and it may be possible for a client to use this maliciously. I take no responsibility for anything going wrong.