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.
The core components are:
Some common additional platform-dependent components are:
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 Amzi! Source Code Debugger is used to find and identify errors. It works on interpreted, compiled and remote Prolog components. Other debugging tools are available for use outside of the listener environment. See Debugging Programs.
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.
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):
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.
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:
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.
The tools just described are all available from the operating system command line using the specified program names. The tools are also gathered together along with many additional capabilities under the Eclipse Integrated Development Environment (IDE).
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.
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.
Next, we recommend you run through "A Quick Tutorial" which follows next, then the "IDE Quick Start". 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 ©1987-2011 Amzi! inc. All Rights Reserved. Amzi! is a registered trademark and Logic Server is a trademark of Amzi! inc.