Declarativa Declarativa

Interprolog version 2.1.2(a)

21 October 2005 (May 2008)

Changes since last version

Please see below.

How to download and install

InterProlog installation does not require a compilation, as it can be installed by copying a directory and editing one file; but the Prolog system(s) to use may need to be compiled, namely under Unix. InterProlog is compatible with Windows XP/2000, Mac OS X and Linux. It requires Java 1.4 and either XSB Prolog 2.7.x, SWI 5.4.x or YAP 5.x. 

Please follow the steps below for your system:



Windows 2000, XP

Mandrake Linux 10.2, Mac OS X


Java Technology Home Page

The Java Runtime Environment will be sufficient if you don't plan to write any Java code AND you're using Windows. Otherwise  you need the Java Development Kit

Download J2SE from site (preferably version 1.4 or later),, and install it some directory MY_JAVA_DIR in your disk
See if it works in a command shell window, by typing MY_JAVA_DIR\bin\java -version  See if it works in a command shell window, by typing MY_JAVA_DIR/bin/java -version 

You should obtain something like this:

java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

Write down (or copy into the clipboard...) the path MY_JAVA_DIR.....bin, the directory where the java executable is. We'll use this below to define the JAVA_BIN environment variable 


XSB Logo

You need to install XSB Prolog

To get and install XSB Prolog 2.7.1 with built-in InterProlog support (interfacing through both sockets and JNI) follow these instructions. XSB Prolog 2.6 is no longer supported, fall back to InterProlog 2.1.1 if you must use it.

Write down (or copy into the clipboard...) the paths for the directories containing the executable images of Prolog. We'll use this below to define the XSB_BIN_DIRECTORY environment variable. 

These will typically be something like





InterProlog is installed by copying a file tree and editing some environment variables in a text file Download the InterProlog zip file from here (2.1.2) or here (2.1.2a, for Java 1.5 and XSB 3.1), or here (2.2a4, for Java 1.6 and XSB 3.3.5 only) which includes this page, and expand it into somewhere in your disk 

Look into the windowsScripts directory. Edit windowsVariables.bat, changing the variables JAVA_BIN, XSB_BIN_DIRECTORY to the values you got in the install steps above

Look into the unixScripts directory. Edit, changing the variables JAVA_BIN, XSB_BIN_DIRECTORY  to the values you got in the install steps above

Mac OS X note: uses some different system directory arrangements take a look at for inspiration

Make sure the script files are executable:
chmod a+x *.sh

That's it :-) 

See if it works by running a run....listener.bat scripts (./ in Unix). A Java window with a Prolog listener should appear, looking perhaps like this:

Alternatively, you can try the Sudoku puzzle editor/solver (change directory separators to / under Unix)

%JAVA_BIN%\java  -DXSB_BIN_DIRECTORY=%XSB_BIN_DIRECTORY%  -classpath ..\interprolog.jar com.declarativa.interprolog.examples.SudokuWindow

See the sources in com/declarativa/interprolog/examples for more information; subdirectory SudokuPuzzles contains... puzzles, in a simple Prolog format.

You can optionally run the standard test suite, using the script testit; when finished successfully (after about a couple of minutes in a 400MHz Pentium) the following window will appear:

If things don't go well: first make sure the steps above were done properly; then open a command shell window, cd to the interprolog212 directly, run the failing script with -debug afterwards, and email the console log to

For example, to make runXSBSPlistener.bat report debugging information edit the command line to

%JAVA_BIN%\java -classpath %CLASSPATH%;..\interprolog.jar com.declarativa.interprolog.gui.XSBSubprocessEngineWindow -debug



Using it

For Prolog development, use runXXXSPListener, which acts as a simple graphical front-end to the full Prolog system through a SubprocessEngine (using sockets), allowing you to get multiple solutions, Prolog textual I/O etc. runNativeListener uses the JNI interface, which lacks the traditional top level

Try some Prolog goals, such as browseTerm(vp(np(interprolog),verb(working))), which should display a tree. You may drag your Prolog source files into the listener window for consulting, or use the menu "File/Consult" . Edit the files with you favorite editor.

Some documentation:

  • Java: Tutorial, Reference (your JDK installation may include this)
  • Prolog
  • InterProlog: introductory paper, Java-side API, Prolog-side predicates, FAQ. See also the CHANGES.txt file, and comments in sources.

Please let us know what you're using it for: Enjoy!

Miguel Calejo

Improvements over version 2.1.2

  • Version 2.1.2a introduces a fix in handling path names, to support XSB Prolog 3 and later

Improvements over version 2.1.1

  • Additional program example: a graphical Sudoku puzzle editor and solver
  • PrologEngine is now an interface, for the sake of flexibility; most of the old PrologEngine functionality moved into the new AbstractPrologEngine class, courtesy of Chris Rued at XSB Inc
  • Several bug fixes, mostly courtesy of Tanya Vidrevich and Chris Rued at XSB Inc.
  • Additional control creating (XSB) NativeEngines, by specifying Prolog startup arguments in the constructor
  • New method PrologEngine.getPrologNumericVersion, useful for scenarios depending on the functionality of specific Prolog versions
  • InterProlog threads now properly killed on PrologEngine.shutdown()
  • Minor changes to the console listener scripts, extra test cases

Known limitations:

Use at your own risk; bug reports welcome except for the following.

  • Object grammar does not support conversion of Java doubles and longs to Prolog numbers, but it recognizes and generates them
  • See comments in streamcontents/4 in com/declarativa/interprolog/interprolog.P for some limitations on serialization of complex (e.g. AWT) objects
  • Changing the Prolog top level prompt handler would break communication with Java
  • The javaMessage predicate performs no coercion of basic type arguments (e.g., if a formal parameter is long then an actual parameter with int is not acceptable), only of object types (e.g. the actual parameter can be a subclass of the formal parameter).
  • NativeEngine (XSB) not working on Windows 2000
  • Cannot use floats on XSB Prolog on Mandrake Linux 10.2, cf. reported bug  (but they wok fine on Mac OS X)
The information and InterProlog software referred in this page are © Declarativa/XSB Inc. and are provided to you under the terms of the GNU Library License, no warranties, authorship reference mandatory etc. Other items are © their legitimate owners. For further or more actual  information please contact

 Declarativa - Serviços de Informática, Lda.,  fax: +351-22-030-1511  tel: +351-22-030-1580
UPTEC - Parque de Ciência e Tecnologia da Universidade do Porto (GoogleMap)
Rua Actor Ferreira da Silva 100 4200-298 Porto Portugal