... system1.1
Many of the Prolog components of XSB were originally based on PSB-Prolog [61], which itself is based on version 2.0 of SB-Prolog [21].
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... interface1.2
InterProlog is available at www.declarativa.com/InterProlog/default.htm.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... handlers 1.3
We are approaching compatibility in the use of ISO-errors for ISO predicates, but in Version 3.0, we aren't quite there yet.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... 2.1
64-bit XSB was broken in a few recent releases, because the developers did not have access to a 64-bit machine. Access to a 64-bit machine is recent at the time of release of Version 3.0.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... results).2.2
This convention does not apply to the subdirectories of the examples directory, which illustrate advanced features of XSB.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... needed 3.1
In XSB, all extensions except '.pl' -- (default '.P', '.H', '.xwam', '.D' (output by mode inferencing), and '.A' (assembly dump) -- are defined in C and Prolog code using macros in $XSB_DIR/emu/extensions_xsb.h and can be changed by a user if desired. Of course, such a step should not be taken lightly, as it can cause severe compatibility problems.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... XSB 3.2
Other types of files may be associated with foreign code -- see Volume 2.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... symbols 3.3
Operator symbols can be exported as any other symbols, but their precedence must be redeclared in the importing module.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
...usermod3.4
The standard predicates of XSB are listed in $XSB_DIR/syslib/std_xsb.P.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... code 3.5
Further information on xsbdoc can be found in $XSB_DIR/packages/xsbdoc.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... interface 3.6
Such predicates are sometimes called ``built-ins'' in other Prologs.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... database 3.7
In XSB, reconsult/[1,2] is defined to have the same actions as consult/[1,2].
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... XSB3.8
Any parallelisation directives (parallel) are simply ignored by the compiler, but do not result in syntax errors to enhance compatibility with various other earlier versions of PSB-Prolog.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... systems3.9
The most common uses of mode declarations in Prolog systems are to reduce the size of compiled code, or to speed up a predicate's execution.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... factoring3.10
Unification factoring was once called transformational indexing, hence the abbreviation ti in the compiler directives
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
...ChKW93 4.1
Sporadic attempts are made to make XSB ISO-compliant, contact us if you have a problem with syntax.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
...sec:CompilerOptions. 5.1
The reader may have noted that table/1, is referred to as a directive, while auto_table/0 and suppl_table/0 were referred to as declarations. The difference is that at the command line, user can execute a directive but not a compiler declaration.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... -- 5.2
Formally, $C$ and $S$ are variants if there are substitutions $\theta_1$ and $\theta_2$ such that the ranges of $\theta_1$ and $\theta_2$ consist only of variables, and $C\theta_1 = S$, and $S\theta_2 = C$.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... 5.3
Formally, $T_1$ subsumes $T_2$ if there is a substitution $\theta$ whose domain consists only of variables from $T_1$ such that $T_1\theta = T_2$.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... 3.0 5.4
Many other scheduling strategies are possible. For instance, [28] describes a tabling strategy implemented for the SLG-WAM that emulates magic sets under semi-naive evaluation. This scheduling strategy, however, is not available in Version 3.0 of XSB.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... SCC 5.5
XSB's implementation maintains a slight over-approximation of SCCs - see [26].
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... program 5.6
LRD-stratifiedstratification may be reminiscent of the Subgoal Dependency Graphs of Section 5.2.2 but differ in several respects, most notably in that stratification considers only cycles through negative dependencies.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... streams6.1
For backwards compatibility, the default input stream can also be aliased by user or userin, and the default output stream by user or userout.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... release6.2
We also note that the ISO Prolog evaluable functors sign/1, float_round/1, float_truncate/1, float_integer_part/1 and float_fractional_part/1 are not implemented in Version 3.0.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... argument 6.3
sk_not/1 replaces the 't not'/1 predicate of earlier XSB versions whose implementation and semantics were dubious.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... terms 6.4
Arithmetic comparison predicates that may evaluate terms before comparing them are described in Section 6.3.1.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... executed 6.5
In Version 3.0, unifiable/3 is written as a Prolog predicate and so is slower than many of the predicates in this section.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... flags 6.6
The ISO flags char_conversion and double_quotes are not yet implemented.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... thread-private) 6.7
For compatibility with older Prologs, there is also an abolish/2 which takes Pred and Arity as its two arguments.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... PredInd 6.8
XSB throws an error in this case because garbage collection for abolished predicates has not been implemented (unlike for retract(all) and various table abolishes). Besides, you shouldn't be abolishing a predicate that you could backtrack into. What were you thinking?
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... operations 6.9
In Version 3.0, loading code dynamically can also be useful when the clauses contain atoms whose length is more than 255 that cannot be handled by the XSB compiler.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
...z 6.10
For backward compatibility, 0 and 1 are also allowed.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
...z 6.11
For backward compatibility, 0 and 1 are also allowed.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
...) 6.12
Dao Tran Minh contributed to implementing this functionality.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... efficiency 7.1
Future versions may offer more powerful garbage collectors for shared predicates.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... threads 7.2
In Version 3.0, tabled predicates using call-subsumption are always private; an attempt to make such a predicate thread-shared throws an exception.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... otherwise 7.3
This behavior can, of course, be overridden by embedding goals within catch/3 and handling errors separately, or simply by adding a default user error handler: see Chapter 11 for details.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... cancellation7.4
While interrupt vector is not checked upon every SLG-WAM instruction, it is checked on every call and execute instruction, and should should be suitable for almost any need for cancellation.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... deadlock 7.5
This error case handles the EDEADLK return code on MacOS X, and other platforms.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... deadlock 7.6
This error case handles the EDEADLK return code on MacOS X, and other platforms.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... 7.7
Note that this traversal is necessary since the position of $T_{cons}$ may in the queue may not be valid due to the addition and deletion of terms by other threads.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... 0$\}$.10.1
A term like
$\{$foo$\}$ is just a syntactic-sugar for the term
'$\{\}$'(foo).
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... brackets.10.2
Readers familiar with Quintus Prolog may notice the difference in the treatment of the various kinds of not. For example, in Quintus Prolog a not/1 that is not enclosed within curly brackets is interpreted as a non-terminal grammar symbol.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... concepts 11.1
Code for this example can be found in $XSBDIR/examples/exceptions.P.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... errors 11.2
We note that XSB's system predicates are in the process of being updated to handle these errors.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... errors 11.3
C functions for throwing terms and ISO-style errors are described in Volume 2, Chapter 3 Foreign Language Interface.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... on11.4
cf. the default system error handler, which performs these functions, if needed.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
... error 11.5
The representation of streams in XSB is subject to change.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.