Quick Overview

Amzi! Prolog + Logic Server consists of core components that are available on all platforms, and additional components that are platform dependent. This overview discusses the components and how they work together to create Prolog applications, either for stand-alone or embedded use.

Components

The core components are:

Some common additional platform-dependent components are:

Relationship of Files and Components

Listener/Debugger

Normally Prolog code is developed using a Prolog interpreter, also called a "listener." The listener directly executes source code, which is stored in a plain text file (.pro file), or typed in directly at the ?- prompt. Developing an interpreted Amzi! Prolog module consists of these steps (the corresponding IDE commands are given in parentheses):

  1. Enter and edit your source code (using File/New to create a new file)
  2. Consult your source code file into the listener (using Listener/Consult)
  3. Issue Prolog queries to test your code and use the listener debugger, as needed (using Listener/Debug on)
  4. Respond to runtime errors
  5. Modify your source code to fix the problems
  6. Reconsult your source code file into the listener (using Listener/Reconsult, which will automatically save all modified source files/windows)
  7. Goto step 3 until your module works

Debugger

The Amzi! debugger is used to find and identify errors. It works on interpreted source code. The debugger can only be invoked from, and used within, the listener. In order to step through code, you need to consult the source code form of the module.

Other debugging tools are available for use outside of the listener environment. See Debugging Programs.

Intermixing Interpreted and Compiled Code

The Amzi! listener allows you to load static (compiled .plm) code as well as consulting dynamic (source .pro) code. You can intermix both in the same application and listener session. This allows you to keep code under development in source form, and debugging code in compiled form.

Compiler

Interpreted code is normally used only for dynamic data, debugging and experimentation. Once a module is completed, it is usually compiled into an object module (.plm file). No source code changes are required before compiling.

The development cycle is extended with the following steps to compile working modules, while keeping modules under development interpreted (in source form):

  1. Compile working source files into object files, which can be consulted into the listener along with the source files still under development
  2. Repeat steps 1-9 until all the modules in the application are working

Compiling has a number of advantages. Compiled code runs faster than interpreted code. Compiled programs that have recursive calls will run longer before exhausting stack and heap resources.

The object file contains byte code instructions for the Logic Server, which is a Prolog virtual machine. The Amzi! Logic Server is an implementation of David Warren's Abstract Prolog Machine (WAM). In the Amzi! implementation, the byte code format of compiled files is machine independent, so compiled Amzi! code can be run on any platform that has an implementation of the Amzi! Logic Server.

Linker

Once an application has been debugged, the object files (.plm) are linked into a single executable load module (.xpl file) that can be embedded in a C/C++, Java, Visual Basic, Delphi, Web Server or other program, or run as a standalone program.

The final two steps of Prolog development are then:

  1. Link the .plm files together into a single .xpl file.
  2. That file is now ready for use with the stand-alone runtime, or for an embedded Logic Server API application.

The linker automatically links in a copy of the standard Amzi! library alib.plm into each .xpl file. You may also want to link in other libraries such as the list utilities library.

Interactive Development Environment (IDE)

The tools just described are all available from the operating system command line using the specified program names. The tools are also gathered together under a single Integrated Development Environment (IDE) for Windows.

The IDE allows you to run the listener with its debugger, the compiler, the linker and the runtime in a graphical (windowing) environment. It also includes an editor and the ability to define projects. Projects provide a convenient means to organize multi-module applications.

Stand-Alone Runtime

The Amzi! runtime is a simple program that loads a .xpl file and executes its main/0 predicate. The simplest distributable application is made up of the runtime, the Logic Server, and an application .xpl file.

Summarizing, the full steps for building a stand-alone Prolog application are as illustrated.

An Amzi! application must have one .xpl file, and only one .xpl file. However, that .xpl file can consult as many additional source files (.pro) and compiled object files (.plm) as needed.

An Amzi! application might also include a configuration file (.cfg file) which specifies the sizes of the heaps and stacks, and gives you control over other operational parameters of the Amzi! runtime.

Embedded Applications

The programming interface to the Amzi! runtime is called the Logic Server API. It provides over 50 functions that, in large part, mimic the functionality of the Prolog listener. You can load source and object code, issue queries, map the results of those queries to variables, assert new facts, build/decompose lists and structures and more.

The Logic Server API is provided on all platforms as a native C/C++ interface. It is also available, depending on platform, for other languages such as Java, VB, and Delphi. Many customers have accessed it from other tools and languages as well, using that tool's or language's capabilities for interfacing with dynamic libraries (.dll under Windows, .so under Unix).

The Logic Server API also lets you define your own extended predicates for Prolog, in effect, letting you customize the Prolog runtime environment. The database extensions to Amzi! are an example of this type of use.

The Logic Server supports multiple, simultaneous Prolog sessions, so one Logic Server can service multiple users in a server-based architecture. From object-oriented languages, such as C++ and Java, this is done simply by specifying a 'new' instance of the Logic Server class.

Where to Go Next?

Next, we recommend you run through "A Quick Tutorial" which follows next. If you plan to embed Prolog code in other applications, you can follow the tutorial for the appropriate 'hello' samples which are described in the Logic Server API section.

There is also a detailed introduction and reference section for each of the tools described above.



Copyright ©1995-2006 Amzi! inc. All Rights Reserved. Privacy Policy.
Amzi!, KnowledgeWright and WebLS are registered trademarks and Adventure in Prolog, Logic Server, Logic Explorer, Adventure in Prolog and Subscription Plus are trademarks of Amzi! inc.