SWI Prolog

macOS

Freely downloadable directly from swiprolog.org, stable version here, installs into /Applications/SWI-Prolog.app/Contents/MacOS/.

The SMT Parser uses the embedded Janus Python interface.

How to check the version

In the Terminal shell, type swipl.

If not found, install it either from SWI Prolog directly, or Homebrew or MacPorts (see below). If installed but still not found, check your PATH. Shell command echo $PATH returns a colon (:) separated list of directories. If the Prolog directory is not present, you can add it for this session using Shell command export PATH=directory:$PATH, where directory is replaced with the correct SWI Prolog directory for your installation, or place the command permanently in the startup file .bash_profile in your home directory if Bash is your Shell program. If you use zsh instead, edit .zprofile in your home directory instead. Then start up a new Terminal window and .bash_profile/.zprofile will be read.

Banner below reveals the version, here 9.2.6. Why do we care? Well, the Janus Python interface is bundled with SWI Prolog, beginning with version 9.2.
The Prolog command ?- ensure_loaded(library(janus)). loads the package.

$ swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 9.2.6)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- ensure_loaded(library(janus)).
true.

?- 

Also, SWI Prolog is available on macOS from the brew package manager (brew.sh) eco-system, see package swi-prolog here, installing into /opt/homebrew/bin/, or MacPorts, see stable package here or development version here, installing into /opt/local/bin/.

On versions earlier than 9.2, Janus is not present, e.g. see below:

$ /Applications/SWI-Prolog.app/Contents/MacOS/swipl
Welcome to SWI-Prolog (threaded, 64 bits, version 8.4.3)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.

For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).

?- ensure_loaded(library(janus)).
ERROR: source_sink `library(janus)' does not exist
ERROR: In:
ERROR:   [20] throw(error(existence_error(source_sink,...),_20596))
ERROR:   [16] '$resolve_source_path'(library(janus),_20628,[if(not_loaded)]) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:2428
ERROR:   [15] '$load_file_e'(library(janus),user,[if(not_loaded)]) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:2404
ERROR:   [14] '$load_file'(library(janus),user,[if(not_loaded)]) at /Applications/SWI-Prolog.app/Contents/swipl/boot/init.pl:2373
ERROR:    [9] toplevel_call(user:user: ...) at /Applications/SWI-Prolog.app/Contents/swipl/boot/toplevel.pl:1158
ERROR: 
ERROR: Note: some frames are missing due to last-call optimization.
ERROR: Re-run your program in debug mode (:- debug.) to get more detail.
?- 

Windows

By default, the SWI Prolog installer does not update the PATH.

On Windows PowerShell, see if the location of the swipl executable is on the PATH using Get-Command:

The installer stores the SWI Prolog executable as C:\Program Files\swipl\bin\swipl.exe. You can type the complete path as follows:

You can also add the directory C:\Program Files\swipl\bin to your PATH if it's not there. Alternatively, you can run the SWI Prolog app directly from the Start menu.

Note: in the above picture, both nltk and nltk_data have already been installed separately.


Last modified: Tue Aug 13 19:13:51 MST 2024