Frequently Asked Questions




Logic Server

Logic Server Extensions and Extended Predicate



Changing the Font in the Debug Views

The font for the Listener and Debug Listener views can be changed in Eclipse by selecting Window | Preferences | Workbench | Fonts. However, if you need to change the font for the views that display the Prolog stack and variables you need to change your 'Message Text' font in your operating system. For Windows, open the Control Panel | Display | Appearance and change the font for the 'Message Box'.


Amzi! Eclipse Initialization Failed

Check the following items:

  1. At a command prompt (in a Windows command box, or Unix terminal window), type 'set' to check the setting of the AMZI_DIR environment variable. It should point to the directory path ....\amzi_X-X-X\ap+ls
  2. Delete any old copies of amzi.dll or on your PATH (or LD_LIBRARY_PATH in Unix). Windows users check your windows\system or system32 directories.
  3. If the message indicates a file could not be opened, check that file exists in your amzi_X-X-X/ap+ls/abin, bin or lib subdirectories and the file is not corrupted.



Those who remember Prolog from the mid 1980s probably remember both the tremendous excitement raised by a logic programming language, and the disappointment of poor performance. That perception lingers today.

But the situation has changed. Prolog is still a tremendous tool for intelligent applications, and it is fast!

Has Prolog technology gotten faster over the last decades? No, but in the 1980s a lot of effort was put into making Prolog as fast as it could be.

And through the 1990s and into the 2000s machines have gotten incredibly fast.

The Rubik's Cube sample included with Amzi! used to take 4-5 minutes to reach a solution in the mid 1980s. Solution times are now measured in milliseconds. That's a lot of intelligence and search applied in a very short amount of time.

And the supporting software that runs on today's machines has gotten more complex, taking advantage of the faster machines. The result is Prolog is extremely fast when compared to other components.

Customers running Amzi! as a back-end logic server to Internet applications report that Prolog execution times are insignificant compared to other parts of the system.

It's all relative, but the result is, today, Prolog is extremely fast.

Program Runs Interpreted but not Compiled

The main reason compiled code behaves different from interpreted code, is discontiguous clauses. These are allowed in the interpreter (listener) but not in compiled code.

Often times there are discontiguous clauses due to typing errors:


This is three a/3 clauses followed by one a/2 clause followed by another a/3 clause, which will be lost be it is discontiguous from the other a/3 clauses.

If you look closely at the compiler output you might notice a stray clause.

If you really have intentional discontiguous clauses, you can specify that with a discontiguous directive:

:- discontiguous a/3.

The compiler then links separate code blocks together.

Predicates with Many Clauses e.g. Wordnet

The Wordnet files make an interesting test case of predicates with large numbers of clauses. One Wordnet file, the main dictionary, has 174,000 clauses. Wordnet is a thesauraus like database, with a Prolog version, that is fun to play with.

Some comments:

XPL Files and Runtime Library

Part of the Amzi! runtime is implemented in Prolog. That part is in alib.plm. Prolog will not run correctly unless alib.plm in loaded. The linker automatically links alib.plm with each .xpl file. This is why it is necessary to run .xpl files, that is, .xpl files have a copy of the required alib.plm runtime predicates.

Sometimes it is desired to create an application architecture, called from a Logic Server host language program, that dynamically loads/consults Prolog modules. It still needs a .xpl file to start with to get alib.plm. To do this you can create a dummy .xpl file by calling alnk with just the argument 'dummy' or whatever else you want, and no .plm files.

For example:

A Logic Server application can now load dummy.xpl, and then dynamically load/consult any other Prolog files as required.

Logic Server

Linking with Borland C++

Borland C++ requires a different .lib format than Microsoft Visual C++. The amzi.lib file distributed with Amzi! is the Microsoft version.

To link with Borland C++, you need to run Borland's implib utility on amzi.dll. This can be done from the command line:

There should be a copy of amzib.lib in the amzi/lib directory.

Logic Server Extensions and Extended Predicates

How to create an LSX in Delphi

This was contributed by a customer who figured out how to make an LSX in Delphi.


Backslash (\) woes in Windows file names

This is all a very nasty business. I've often wondered how much further advanced computer technology would be if so many programmer hours weren't spent trying to sort out the \ in DOS paths, which is also the C symbol for escape sequences in strings. (Maybe its why Linux with its / in paths moved ahead so fast? :) )

Amzi! is implemented using C++, so it uses the same string escape sequences. The flag, string_esc, can be used to turn off escape processing and allow \ to be an ordinary character.

The part of the Amzi! system that cares about string_esc is the Prolog term reader. That is, the code that is called into action when presented with terms to read, such as when consulting a file, or compiling a file, or reading input from the ?- in the listener. So when you turn that flag on or off, it affects all terms read after the flag was set.

A simpler solution to the problem of pathnames was introduced in the 6.x release. In that release, a forward slash (/) is allowed in file paths for Windows. In fact, either slash is allowed for filenames in running either Windows or Unix.

And a built-in predicate tilt_slashes/2 is provided to allow the creation of the correct paths for a given platform. For use with other applications.

I/O in Embedded Windows Applications

Windows does not support standard input/output, so without doing something special or tricky, write/1, nl/1, and other I/O statements will not work when encountered in an embedded program (Java, VB, Delphi, C++, etc.) running on Windows.

Three options:

Return information in predicate arguments

Typically, the Prolog program is used as a 'knowledge' server, so the architecture of the program is the host language calls Prolog to get some answer.

Consider a trivial example of a predicate to add two numbers. It might look like this in a stand-alone Prolog program:

add_numbers(A,B) :-
    C is A + B,

You might use this for an embedded version:

add_numbers(A,B,C) :-
   C is A + B.

And your host language program calls add_numbers/3 and uses lsGetArg to pick up the third argument, which is the answer.

Provide your own I/O predicates

You can write your own extended predicates in the host language that provide I/O functions. See the Logic Server documentation on extended predicates and various samples for the host language you will be using.

You could define a predicate ext_output/1 in the host language that did whatever you wanted, say put up a message box, or write to a window. Your program would then call it for output, rather than write/1:

add_numbers(A,B) :-
   C is A + B,

How can you run the same program both in pure Prolog (for testing for example) and embedded?

Call your I/O output predicate a more generic name, like output/1:

add_numbers(A,B) :-
   C is A + B,

And define it to use ext_output/1 if it exists, otherwise use write/1:

output(X) :-
output(X) :-

Create your own Prolog I/O stream

You can create your own I/O stream that will accept normal Prolog I/O. See Logic Server documentation for details.

This is the special or tricky option, and is not generally recommended, except for special types of applications. One example of which is the Prolog listener in the Amzi! IDE. It creates a special I/O stream that allows Prolog I/O to read/write from a Window.

Copyright ©1987-2011 Amzi! inc. All Rights Reserved. Amzi! is a registered trademark and Logic Server is a trademark of Amzi! inc.