Before describing how to program using tabling it is perhaps worthwhile to review some of the goals of XSB. Among them are:
Goals 1 and 2 are addressed by XSB's engine, which in Version 2.5 is based on a memory-copying version of a virtual machine called the SLG-WAM. The overhead for SLD resolution using this machine is small, and usually less than 5%. Thus when XSB is used simply as a Prolog system (i.e., no tabling is used), it is reasonably competitive with other Prolog implementations based on a WAM emulator written in C or assembly. For example, when compiled as a threaded interpreter (see Chapter 3) XSB Version 2.5 is about two times slower than Quintus 3.1.1 or emulated SICStus Prolog 3.1.
Goals 3, 4 and 5 have been nearly met, but there are a few instances
in which interaction of tabling with a Prolog construct has not been
accomplished, or is perhaps impossible. Accordingly we discuss these
instances throughout this chapter. XSB is still under development
however, so that future versions may support more transparent mixing
of Prolog and tabled code (e.g. allowing tabled predicates in the
scope of \+/1
) or adding Prolog functionality to tabled
predicates or operators (e.g. allowing non-ground negation in tnot/1).