Skip to main content

jswip

A Jupyter Kernel for SWI-Prolog.

Inspired by madmax2012/SWI-Prolog-Kernel and now using PySwip.

USE WITH CARE!

This kernel is only barely tested using jupyter lab on debian linux. If anyone tests it e. g. on plain jupyter and/or windows feel free to open a ticket to report success and/or failure.

I have only just started out learning prolog and have not tested this kernel with all language constructs of prolog yet. There might still be problems with more advanced prolog stuff.

Usage Notes and Limitations

You should split your knowledgebase and your queries into different cells. KB entries (facts and so on) will be retained as long as the kernel is running. This means that if you run a cell containing facts twice the facts will be sent to swipl twice. This will typically not result in errors but in odd outputs when querying the KB.

Should you receive bogus output when running queries restart the kernel and make sure you run any cell containing something other than queries only once.

Every query must start with ?-.

Working example:

man(socrates).
mortal(X) :- man(X).

?- mortal(socrates).
?- mortal(X).
?- mortal(bob).

Will output.

true.
X = socrates.
false.

Keep in mind that for some queries there are lots of answers. For the kernel to always succeed in a reasonable amount of time the default output limit to any one query is 10 answers. You can influence this limit by the following syntax.

?- someQuery(...) {LIMIT}.

Where LIMIT is replaced by the maximum number of answers that will be displayed for this query. It is not very smartly parsed (sorry), so there must be no spaces inside the curly braces or in between the closing curly brace and the period. Not like this: {1} . or this { 1 }.

A limit value of -1 means no limit. Be careful with this!

Supported environments

Only pyhton3 is supported (anybody still using python2 should really have upgraded by now...) and it was only tested on linux as I have no jupyter installation on windows. In theory it should work on windows though.

Installation

  1. Install SWI-Prolog.
  2. Install jswipl python3 -m pip install --upgrade --user jswipl
  3. Change directory to your jupyters kernel directory. Typically ~/.local/share/jupyter/kernels.
  4. mkdir jswipl && cd jswipl
  5. Install kernel spec: wget https://raw.githubusercontent.com/targodan/jupyter-swi-prolog/master/kernel.json
  6. Restart jupyter
  7. Profit

Upgrading

Keeping up to date is as simple as running python3 -m pip install --upgrade --user jswipl from time to time.

Contributing

Feel free to open tickets if something goes wrong or open pull requests. If you open a pull request do open it onto the develop branch. This repository loosely adheres to the git flow workflow. The master branch is the branch on which only "released" versions are. Anything in development goes into the develop branch.

Please do keep in mind that this is just a very small side project and I am unlikely to sink tons of development time into this. However I will try to answer on any issues even if it's just a quick "Yup, would be nice. Please open a pull request someone." and I'll try to handly pull requests quickly.

Anyone who's interested in becoming a co-maintainer: open an issue and let me know. :)

Metadata

Release files for jswipl 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jswipl 1.0.2
File Size Uploaded Provenance Actions
jswipl-1.0.2.tar.gz 5.2 kB Without provenance Details for jswipl-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for jswipl 1.0.2
File Interpreter ABI Platform Actions
jswipl-1.0.2-py3-none-any.whl Python 3 none any Details for jswipl-1.0.2-py3-none-any.whl

Total release size: 12.0 kB

Release files / jswipl-1.0.2.tar.gz

Download URL jswipl-1.0.2.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3716198ce99e3e986a1c2830ac8580e5bd29ddd89d3784c4c963301ca9ec5e3e
BLAKE2b-256 checksum
How to use checksums
c3f6840d0446ba7cc94e96a2d421e5c67fa9bdf5f17aecd532ad7f80e991e500
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Release files / jswipl-1.0.2-py3-none-any.whl

Download URL jswipl-1.0.2-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f033c8f0a44b17c23f5054c49ed8bc42f9047a5205679e74e66c01340cbf72a4
BLAKE2b-256 checksum
How to use checksums
faf67e4f4debc943b0d20107f666a3f3667ba771d282afab47d46909134ba392
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

Security for jswipl 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page