[SLP-Homepage]    [Source Modules]    [Manual]    [Run]    [Examples]
 

Version Settings

Different versions of SLP can be built by setting #define-switches in this include file:


Operating System Selection:
VER_UNIX:
#define VER_UNIX
VER_UNIX should be defined if this program is built under a UNIX operating system. I tested it with gcc under Solaris. If VER_UNIX is defined, VER_SIGNAL will also be selected, and VER_IOSTREAM will not be selected (see below). VER_UNIX can also be defined in the makefile (on the compiler command line): The code in ver.h checks whether VER_UNIX or VER_WINDOWS are already defined before the setting in ver.h is executed.
VER_WINDOWS:
#define VER_WINDOWS
VER_WINDOWS should be defined if this program is built under a Windows-style operating system. I tested it with Visual C++ 6.0 under Windows Me. Currently, VER_WINDOWS is simply the negation of VER_UNIX. So VER_SIGNAL will not be selected, and VER_IOSTREAM will be selected (see below). Having an explicit symbol for the negation is also important for the possibility to select VER_UNIX or VER_WINDOWS on the command line. The setting in ver.h is only the default if none of the two symbols is already defined.


CGI Parameters:
VER_CGI:
#define VER_CGI
If this symbol is defined, a CGI program will be built (to be executed by a web server with the method POST). On the one hand, this means that all output will be in HTML. Therefore, the module out heavily depends on this symbol. On the other hand, there are security requirements for CGI programs. If VER_CGI is defined, the module in_file checks that the file name consists of at most 8 characters, which must all be letters. Also, the directory VER_CGI_EXDIR is placed in front of the file name which the user has specified.
VER_CGI_EXDIR:
#define VER_CGI_EXDIR "/home/sbrass/public_html/slp/ex/"
This defines the directory in which the CGI version of the program can read input files. Users of CGI programs are anonymous and potential hackers. This directory should contain only example files, which can also be published on the web. The string VER_CGI_EXDIR simply is a prefix to the user-specified filename. So it normally contains a slash / at the end. Currently, VER_CGI_EXDIR is defined in the makefile for the UNIX version, not in ver.h.


Debugging Parameters:
VER_DEBUG:
#define VER_DEBUG
If VER_DEBUG is defined, the run-time assertion checks in check.h are activated. In addition many classes define a method valid() which checks invariants of the data structure. Also, many classes get a member Magic which contains a magic number to identify objects of that class. If VER_DEBUG is not defined, the compiled binary program is a bit smaller and runs slightly faster. So at least before performance comparisons with other logic programming systems, SLP should be compiled without VER_DEBUG set.


Some Important Limits:
VER_MAX_HEAD_LIT:
static const int VER_MAX_HEAD_LIT = 256;
This is the maximal number of head literals in rules and conditional facts. It is possible to write rules which generate very long disjunctions in the computation, but such disjunctions anyway are difficult for the performance. I introduced this constant because it was easier to use fixed size arrays as intermediate storage while a conditional fact or rule is created than dynamic lists. But once we are finished with the new rule/conditional fact, it is transformed into a linked list. So no storage is wasted if this constant is made quite big. However, there is an array on the stack allocated of this size, so there might be problems if it is set too big (this could easily be changed if it leads to a problem).
VER_MAX_BODY_LIT:
static const int VER_MAX_BODY_LIT = 256;
This is the maximal number of positive body literals in rules. There is only one array in conv.cxx of this size for collecting positive body literals during the clause conversion. This array is static, i.e. not allocated on the stack, so there should be no problem to increase it as needed.
VER_MAX_NEG_SIZE:
static const int VER_MAX_NEG_SIZE = 256;
This is a limit for the sum of default negations and the negated literals inside them per clause. So if this limit is set to 256, and all default negations consist of only one literal, there can be 128 default negations in a clause. Note that an array of this size is allocated on the stack. Again, this is easy to change if needed.
VER_MAX_COND_NEG:
static const int VER_MAX_COND_NEG = 256;
Maximal number of default negations per clause (conditional facts and rules).
VER_MAX_COMPAR:
static const long VER_MAX_COMPAR = 2147483647L;
This is the maximal number of comparisons done for testing conditional facts for redundancy. It should be simply the largest long value. It can be set to a smaller value to restrict computation time (for instance, when SLP is used as a CGI program and you don't want to allow very complicated examples). If even the largest long value is a restriction, it would be quite easy to reset all the "Overlaps" counters in all conditional facts once the maximum is reached. Then one could start again from 0.
VER_MAX_VARS:
static const int VER_MAX_VARS = 256;
This is the maximal number of variables in a single input formula. Therefore, also no rule (clause) can have more variables.
VER_MAX_ARGS:
static const int VER_MAX_ARGS = 256;
This is the maximal number of argument terms in a single literal (atomic formula).
VER_BITS_PER_BYTE:
static const int VER_BITS_PER_BYTE = 8;
This is used in the module nint.h to check that the negation number corresponds to a bit in nint_t (unsigned long). I know that it is defined as CHAR_BITS in limits.h, but I didn't want to include limits.h in too many files for a constant that is anyway everywhere the same.
VER_MAX_CRIT_NEG:
static const int VER_MAX_CRIT_NEG = 32;
This is the maximal number of distinct default negations that remain in the residual program. In the current implementation it is limited to sizeof(unsigned long) * VER_BITS_PER_BYTE, since an unsigned long value is used as bitmap (it contains a 1-bit for the true default negations). Because all possible interpretations must be considered, this does not seem a big restriction. However, one only would have to exchange the module nint.h to remove this restriction.
VER_BACKTRACK_POINTS:
static const int VER_BACKTRACK_POINTS = 256;
This is the size of the stack for backtrack points in the model generator. There will not be more than one backtrack point for each fact that appears inside a critical negation, so the current setting of 256 is very large when there can be only 32 critical negations.


Derived Settings:
VER_SIGNAL:
#define VER_SIGNAL
If VER_SIGNAL and VER_DEBUG are defined, the procedure check_init (see the check module) defines signal handlers for SIGSEGV, SIGBUS and SIGFPE. These are three common runtime errors. If SLP is runs as CGI-program, one normally gets no information if it crashes (maybe "internal server error"). With VER_SIGNAL and VER_DEBUG set, one gets at least the information that an exception happened in SLP (and which kind of exception). In Visual C++, SIGBUS is not defined, and the documentation says that SIGSEGV is not generated under Windows NT - it is only defined for compatibility. Also, the signal handler should not use the functions of the stdio library, and should not generate any system call. So it is anyway not very useful. Therefore, VER_SIGNAL is currently only supported under UNIX. It is automatically defined in ver.h if VER_UNIX is defined.
VER_IOSTREAM:
#define VER_IOSTREAM
With GNU gcc under UNIX, I got warnings when I included fstream.h in the module in_file. Since I couldn't change the system include file, I decided not to use it and to use directly the UNIX system calls like open and read. A small bonus is that this version probably runs a bit faster. But later I used Visual C++ under Windows, and the UNIX system calls are not supported there. But at least there fstream.h generates no warnings, so I chose standard stream IO under windows. VER_IOSTREAM selects the stream input in the module in_file. Other modules already use stream IO, because there I needed only iostream.h which did not generate warnings. VER_IOSTREAM is automatically defined in ver.h if VER_WINDOWS is defined. It is possible to defined VER_IOSTREAM also under UNIX.
VER_CS_ISO:
#define VER_CS_ISO
If VER_CS_ISO is defined, the ISO Latin 8859/1 character set is used. Accented national characters like äöü can then be used in identifiers (predicate and constant names). If neither VER_CS_ISO nor VER_CS_MSDOS is defined, on the Standard ASCII character set is supported. If VER_UNIX is defined, VER_CS_ISO automatically gets defined in ver.h.
VER_CS_MSDOS:
#define VER_CS_MSDOS
This classifies national characters according to some MS-DOS character set. I wrote this code many years ago and haven't tried it. Therefore, it is currently not defined, even if VER_WINDOWS is set.


Implementation:


Stefan Brass (sbrass@sis.pitt.edu), March 8, 2002.    [HTML 3.2 Checked]