The Amzi! runtime engine is a shared library,
amzi.dll under Windows and libamzi.so under Unix. Amzi! Prolog is always run
by a host language program that loads and starts the runtime engine.
Arun is a command line interface to the engine that simply loads a compiled
Prolog file (.xpl file) and calls its main/0 predicate. Arun is, therefore,
the tool to use for running stand-alone command line Prolog programs.
The source code for arun is included in the Amzi! src directory.
arun from the Command-Line
Arun can be used in two ways. You can run
it directly and specify the name of the .xpl file to execute as a parameter:
c> arun wgene
You can also copy arun to the same name as your application. In this
case the .xpl file with the same name as the .exe will be executed:
c> copy arun.exe wgene.exe
The command line listener, alis, and compiler, acmp, are examples of this. Both of these development tools are Prolog programs.
Configuration files (.cfg) give
you the ability to customize your working environment on an application-by-application
basis, most notably in deciding which runtime to use and what stacks to set.
The .cfg files give you three layers of defaults.
- The system as shipped has default values for stacks and the like that
it uses if no .cfg files are found.
- The system looks first for a file called amzi.cfg. This is your tool
for overriding the built-in system defaults.
- When an application runs, it first looks for a .cfg file with the same
name as the application (.xpl file). If one exists, it is used to override
the system defaults, either as set by you or built into the system.
A .cfg file is composed of lines of the form
parameter = value
Comment lines begin with either '#' '%' or ';'.
Configuration parameters can also be set from a host language program
via arguments, rather than through a .cfg file. To do this, use the entry point
lsInit2() rather than lsInit(), with the argument being the parameters in character
string format. Many of the parameters have abbreviations which might be easier
to use when using lsInit2. They are in () after the parameter name.
These parameters affect the
various control stacks used during Prolog program execution. A Prolog cell
is a small internal unit that holds Prolog primitives, such as atoms, numbers,
and list and structure elements.
These parameters affect the size of Prolog terms that can be read or written,
by either the listener, compiler, or any other Prolog program.
These parameters that aid in debugging.
Other system parameters.
Default .cfg Values
The system defaults are listed in the commented out
lines for each parameter in the distributed amzi.cfg file.
Like the configuration
parameters, flags relate to various runtime parameters of Amzi! Prolog. But
flags can be queried, and in some cases set, directly from Prolog.
A flag are queried and set using two built-in predicates:
current_prolog_flag/2 returns the value of a given flag name, FLAG. If FLAG is a variable, current_prolog_flag/2 will backtrack through all of the flags.
set_prolog_flag/2 sets the value of the named flag, FLAG.
All of the configuration parameters can be queried as flags. Some can also
be set and they are listed with the settable flags below.
The following flags can be dynamically set:
Flags controlling Prolog parsing, sorting and I/O
- locale -- A string representing the geographic locale setting used.
The locale is initially set to the default locale for the operating system
being used. To set the locale, provide a value that is a string representing
the locale. Example:
To reset to the system's default locale, provide an empty string (``) as a
- occurs_check -- Attempts to unify cyclic terms can lead to hard crashes
of the Prolog engine. An example would be ?- A = f(A), B = f(B), A = B. The
default is off because: 1) this sort of construct rarely occurs; 2) many cyclic
unifications are caught on output, such as simply ?- A = f(A). ; and 3) there
is a 10% performance overhead to add the check. But sometimes it's nice to
- double_quote_strings -- Strings are normally delimited by backquotes
(`) in Prolog, and doublequotes (") are used as a shorthand for lists
of characters, useful for parsing applications. However, for some applications
where non-programmers are entering data for Prolog applications, it is desirable
to allow the use of the more common doublequotes (") for delimiting strings.
When this flag is on, that happens, and there is no special syntax for character
lists. The default is off.
- preprocessor -- The Amzi! preprocessor can be dynamically turned
on and off using this flag. The default is on.
- string_esc -- For strings and atoms, the backslash (\), called an
escape character, is used to denote special characters, such as a newline
(\n). If a \ is desired as a real \, then \\ is used. This use of \ can be
turned off, so that a \ is a \ by setting this flag to off. This is especially
useful for applications that parse Windows path names. The default is on.
- upper_case_atoms -- For applications where non-programmers are entering
data for Prolog applications, the syntactical use of upper case for variables
can be confusing. This flag changes the Prolog reader to accept both lower
and upper case letters as legitimate starting characters for atoms. When this
flag is on, the only way to represent a variable is with a leading underscore
(_). The default is off.
- vars_sort_equal -- Variables can either be sorted as equals or by
internal storage location. A value of on means sort as equals, off means sort
by location. The default is off.
- undefined_predicate -- What happens when you try to execute an undefined
predicate. A value can either be fail or error. The default is fail.
- utf8io -- Sets the I/O from the engine to UTF-8. Useful for Internet applications. If there is a UTF-8 source file, this can be set using set_prolog_flag/2 in a directive at the beginning of the file so the characters are read in correctly.
Flags controlling arithmetic
- decimals -- The type of number used for non-explicit decimals. For
example, 1.1, 43.78, 0.6543. The choices are:
- real - Infinite precision real numbers.
- float - Floating point numbers.
- floats -- The precision used for floating point numbers. The choices
- single - Single precision floats.
- double - Double precision floats.
- decimal_places -- The number of decimal places displayed when writing
numbers. -1 is the default, and means display all available decimal places.
Does not affect writeq, which always displays all available decimal places.
- epsilon -- The number of fractional decimal places of precision to
use for internal real number series calculations that could exceed reasonable
limits. In particular it affects the sqrt function and the power function
for fractional numbers raised to large powers. It is expressed in as a negative
exponent. For example a value of -18 means results are accurate to 10 ** (-18).
Internally, it is stored as a power of gigadigits (base 10**9) so it is rounded
to a multiple of 9. By default it is 0, which means power functions are exactly
precise, no matter how many digits are required, and square root defaults
to -72 digits.
- delta -- When dividing two real numbers the precision of the answer
might be a repeating decimal. In that case, 'delta' is used to determine how
many of digits of precision to use. It is added to the maximum precision of
either the numerator or denominator. The default is 18, so there are 18 digits
of extra precision on divides. Internally, it is stored as a power of gigadigits
(base 10**9) so it is rounded to a multiple of 9.
- modulo -- If the modulo flag is non-zero and set to a prime number,
then all integer arithmetic is performed modulo that number. See sections
on prime numbers for more details.
The following flags can be queried. Some are part of the ISO standard to allow
applications to make adjustments based on implementation-specific details, such
as whether integers are bounded or not.
- bounded -- Whether integers must lie in a bounded interval. The value
depends on the flag decimals. If decimals = real, then
integers are unbounded (infinite precision), otherwise they are bounded (constrained
to the internal size of an integer, usually 32 bits).
- char_conversion -- Whether a user defined routine can be used for
transforming read unquoted characters. For Amzi! the value is 'off', meaning
character conversion is not supported.
- debug -- Whether the application is running in debug mode or not.
- integer_rounding_function -- The behavior to expect from integer
division (//) with regards to rounding the result. For Amzi! the value is
- max_arity -- The maximum arity of a structure. (255)
- max_integer -- Since Amzi! is not bounded with respect to integers,
the value of this ISO flag is 'not_applicable'.
- min_integer -- Since Amzi! is not bounded with respect to integers,
the value of this ISO flag is 'not_applicable'.
- prolog_copyright -- The copyright for this Prolog.
- prolog_date -- The date of the build.
- prolog_name -- The name of this Prolog implementation.
- prolog_version -- The version number.
- unicode -- Whether the build supports Unicode (wide 16-bit) characters
or not. For Amzi! the value is 'true'.
Copyright ©1987-2011 Amzi! inc. All Rights Reserved.
Amzi! is a registered trademark and Logic Server is a trademark
of Amzi! inc.