Declarativa

# Interprolog version 2.1.2

21 October 2005

## 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:

### Step | ### Comments | ### Windows 2000, XP | ### Mandrake Linux 10.2, Mac OS X
# 1 | 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 java.sun.com site (preferably version 1.4 or later), http://java.sun.com/j2se/1.4.2/download.html, 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
# 2 YAP | You need to install either XSB Prolog or/and SWI Prolog or/and YAP 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. To get and install SWI Prolog (interfacing through sockets, no JNI) just install the standard version (5.4.6 or later) To get and install YAP Prolog (interfacing through sockets, no JNI) just install the standard version (5.0 or later)
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, SWI_BIN_DIRECTORY and YAP_BIN_DIRECTORY environment variables (or just one of them if you only need one Prolog). These will typically be something like
XSB_DIR...config.....bin SWI_DIR...bin \Program Files\Yap\bin | XSB_DIR...config.....bin /usr/lib/SWI_DIR/bin/i686-linux For Yap, /usr/bin
# 3 | InterProlog is installed by copying a file tree and editing some environment variables in a text file | Download the InterProlog zip file from here, 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 and/or SWI_BIN_DIRECTORY and/or YAP_BIN_DIRECTORY to the values you got in the install steps above | Look into the unixScripts directory. Edit unixVariables.sh, changing the variables JAVA_BIN, XSB_BIN_DIRECTORY and/or SWI_BIN_DIRECTORY and/or YAP_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 MacOSXVariables.sh 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 (./run...listener.sh in Unix). A Java window with a Prolog listener should appear, looking perhaps like this: Alternatively, if you're using XSB Prolog 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. If you installed ALL Prologs supported by InterProlog (currently XSB, SWI and YAP), 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 interprolog@declarativa.com For example, to make runSWISPlistener.bat report debugging information edit the command line to `%JAVA_BIN%\java -classpath %CLASSPATH%;..\interprolog.jar com.declarativa.interprolog.gui.SWISubprocessEngineWindow -debug`
# 4 ## 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 (currently available only for XSB Prolog), 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: XSB Manual 1 and XSB Manual 2 (your XSB installation will typically include a Postscript version) SWI Manual YAP Manual 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: interprolog@declarativa.com. Enjoy!

Miguel Calejo
Declarativa

## Improvements over version 2.1.1

- Support for YAP Prolog
- 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

## Improvements over version 2.03

- Multiple PROLOG support: XSB Prolog and SWI Prolog
  - `SubprocessEngine` is now an abstract class, to accomodate the support of multiple Prolog implementations. The "old" SubprocessEngine is now `XSBSubprocessEngine`
  - The interprolog.P is gone from com/declarativa/interprolog; each Prolog implementation has its specific file in this directory, typically in a subdirectory, currently xsb/interprolog.P and swi/interprolog.pl; most of the specific Prolog dependencies are in these files and in PrologImplementationPeer subclasses
  - New method `toString(PrologEngine engine)` in class TermModel, uses the standard startup (not necessarily current) operator definitions for the engine, rather than the common (engine) subset.
- Functional and other improvements
  - `PrologEngine.consultAbsolute(File)`: consults a Prolog file from an absolute path
    Another variant of the deterministicGoal method: TermModel deterministicGoal(TermModel G), useful for inter-Prolog goal calling. For example, the following goal (running in any supported Prolog, say XSB) instantiates a SWI engine and obtains a goal solution for goal G:
    javaMessage('com.declarativa.interprolog.SWISubprocessEngine',SWI,'SWISubprocessEngine'), buildTermModel(G,GM), javaMessage(SWI,SM,deterministicGoal(GM)), recoverTermModel(SM,Solution), javaMessage(SWI,shutdown).
  - More robust PrologEngine.interrupt() handling, by using Prolog throw/catch
  - Improved InterProlog debugging information for SubprocessEngines created with the debug argument true: they now print to System.err ALL Prolog output during startup
- Runtime environment configuration
  - Zero-argument Prolog engine constructors, for easier use in some contexts. For a PrologEngine to be instantiated without a constructor argument, a property must be defined in either file `interprolog.defs` (a Properties file in the format described in http://java.sun.com/j2se/1.4.2/docs/api/java/util/Properties.html , in the directory where the jar file containing the InterProlog classes is) or in the global properties (by using the -D java switch). The properties should include XSB_BIN_DIRECTORY and/or SWI_BIN_DIRECTORY, depending on which Prolog(s) you're using
  - `NativeEngine` now requires as argument (either explicitly or implicitly through the above Properties mechanism) the path to the XSB binary directory as the constructor argument, rather than the base directory as before, to simplify configuration; notice that this has more information than the base directory, eg for XSB it embbeds the consequence of being in a certain operating system.
  - Extra optional constructor argument in `PrologEngine` and subclasses, loadFromJar. InterProlog startup files can now be loaded either from the jar file (as before) or from classname-relative locations in the file system: interprolog.P from ...com/declarativa/interprolog/{xsb or swi} and visualization.P from ...com/declarativa/interprolog/gui/ . Loading from the file system can be useful while fiddling with InterProlog itself and testing changes to these files. There's a simple command line argument ("-nojar") that can be used in listener invocation scripts, see ListenerWindow.commonMain().

### 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).
- YAPSubprocessEngine does not support interrupt() under Windows
- 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 interprolog@declarativa.com