Introduction to PrologJ

Overview

PrologJ is an implementation of the Prolog programming language, written in Java. The implementation is packaged as a single jar file, prologj.jar, that can be used in various ways:

  1. PrologJ can be run as a stand-alone interpreter for Prolog programs, either entered interactively or read from a file. PrologJ also provides a set of debugging facilities for use in interpretive code development.
  2. PrologJ can be used as a compiler to translate a program written in Prolog into a Java source file, which can then be compiled using the Java compiler and run like any other Java program - using prologj.jar as a library. The Prolog program can either contain a main program, or it can provide facilities used by a main program written in Java.
  3. PrologJ provides an API that allows Prolog facilities to be used from within a Java program - e.g. Java code can assert terms into a Prolog database, call asserted terms, retract terms, etc. Once again, prologj.jar is used as a library.

Moreover, PrologJ incorporates several extensions to allow programs written in Prolog to utilize facilities provided by other languages and systems.

  1. PrologJ allows Prolog code to use Java reflection to call code written in Java.
  2. PrologJ allows Prolog code to acess a relational database, provided that the DBMS provides a JDBC driver.

PrologJ incorporates additional support for working with sets, which allow manipulating sets that are represented as lists. (This facility extends the rudimentary support for creating bags and sets included in ISO Prolog).

Finally, PrologJ incorporates support for using fuzzy logic, which allows a goal not only to succeed or fail, but also to partially succeed. This behavior is incorporated in such a way that it must be invoked explictly; by default, PrologJ exhibits standard "crisp" behavior.

Implementation of Standards

PrologJ implements a total of 172 built-in predicates. These include all the built-in predicates of ISO standard Prolog (as described in [ Deransart, Ed-Dbali, and Cervoni 1996 ]), plus all the built-in predicates of "traditional" Prolog (as described in [ Clocksin and Mellish 1994 ] and elsewhere), plus various extensions. By default, all the built-in predicates (except a few special ones provided to support the compiler) are available to interpreted or compiled code; however, the user has the option of explicitly specifying which category(s) of predicates should be available.

PrologJ defines a total of 46 infix and prefix operators, including all those defined in ISO standard Prolog, one defined in traditional Prolog but not in ISO standard Prolog, and several additional operators used by various extensions. By default, all the operators are defined; however, if the user chooses to explicitly specify the categories of predicates to be available, then only the corresponding operators are defined.

PrologJ implements a total of 31 flags, including all those defined in ISO standard Prolog, plus a number of additional flags. (Flags are an addition to Prolog with the ISO standard.) When starting up the system, it is possible to specify flag settings that correspond to the ISO standard, or to a relaxed variant of it, or that produce behavior like "traditional" implementations.

PrologJ implements all the directives defined in ISO standard Prolog, plus a two others that affect the compiling of Prolog code to Java.

PrologJ implements a total of 29 unary and binary functions / arithmetic operations, including all the functions/operators defined in ISO standard Prolog.

File Naming Conventions

The PrologJ system assumes that files containing Prolog source code will have a name that ends with the extension (file type) ".pro". The portion of the file name that preceeds this extension is called the base name of the file. System components that require the name of a Prolog source file allow the file to be specified by its base name alone (E.g. consult(foo) and consult('foo.pro') are equivalent.)

The PrologJ compiler converts a source file into a compiled file, whose name is the same as the base name of the source file from which it was compiled. (E.g if the file foo.pro is compiled, it creates a compiled file foo.java which is translated by javac into foo.class.)

Bibliography

[ Clocksin and Mellish 1994 ] W.F. Clocksin and C.F. Mellish, Programming in Prolog, 4th Edition, Springer Verlag (1994).
[ Deransart, Ed-Dbali, and Cervoni 1996 ] P. Deransart, A. Ed-Dbali and L. Cervoni, Prolog: The Standard, Springer Verlag (1996).

Copyright © 2005 - Russell C. Bjork. See the file See file COPYING in the root directory for copyright information.

Valid XHTML 1.0!