Browse Prior Art Database

Compiling Methods for Translating Prolog to C

IP.com Disclosure Number: IPCOM000102448D
Original Publication Date: 1990-Nov-01
Included in the Prior Art Database: 2005-Mar-17
Document File: 5 page(s) / 181K

Publishing Venue

IBM

Related People

Arbab, B: AUTHOR

Abstract

This disclosure outlines a system for compiling Prolog source code into C source code. The main purpose of this disclosure is to use C as an abstract machine into which Prolog programs are compiled. This is in contrast to using C as an implementation language for an abstract machine, e.g., WAM (1), into which Prolog is to be compiled.

This text was extracted from an ASCII text file.
This is the abbreviated version, containing approximately 28% of the total text.

Compiling Methods for Translating Prolog to C

       This disclosure outlines a system for compiling Prolog
source code into C source code.  The main purpose of this disclosure
is to use C as an abstract machine into which Prolog programs are
compiled.  This is in contrast to using C as an implementation
language for an abstract machine, e.g., WAM (1), into which Prolog is
to be compiled.

      The use of C as the abstract machine, target language for
compilation, allows programs developed in Prolog on a particular
hardware platform to be ported across different hardware platforms
and operating system environments.

      This method demonstrates the extent to which execution of
Prolog programs are made machine-independent.

      In order to execute Prolog, it is common practice to define or
modify an abstract machine, e.g., WAM, into which Prolog programs are
compiled.  By design the abstract machine's instruction set is
defined in such a way as to allow compact code generation and
efficient execution of Prolog programs.

      The abstract machine, e.g., WAM, then is implemented in some
programming language, e.g., C, or a combination of programming
language and machine code for efficiency. Assuming that the abstract
machine is implemented entirely in C, then it can be ported to
different platforms by recompiling the source code which implements
the abstract machine (assuming, of course, that the source code is
available).  In practice, however, this recompilation is not a simple
task,  Depending on the architecture of the hardware, the
implementation of the abstract machine must be changed or fine-tuned,
e.g., stack management and representation of instruction sets, etc.

      The method outlined here completely eliminates the design and
implementation of specialized abstract machines for execution of
Prolog in favor of using an established and portable programming
language as the abstract machine.

      There is a distinction between using a programming language as
an abstract machine and using it to implement an abstract machine.
If a programming language, e.g., C, is being used to implement an
abstract machine (into which Prolog code is finally translated), then
there will be a number of instructions that correspond to stack
management (in fact, WAM has three different stacks usually called
local, global, and trail to manage).  If, however, the programming
language (e.g., C) itself is the abstract machine, then there will be
no need for stack and other management instructions.

      The fact is that these instructions are not needed to
contribute to the efficiency of the generated code corresponding to
Prolog codes.  The purpose of eliminating all instructions related to
management of the abstract machine, however, is to render the
generated code portable and independent of the underlying hardware.
The only remaining dependency, of course, is the presence of a C
compiler for the particular ha...