next up previous contents index
Next: 1.0.0.0.7 Unification Factoring Up: 1. Introduction Previous: 1.0.0.0.5 Fast Loading of   Contents   Index

1.0.0.0.6 HiLog

XSB also supports HiLog programming [13,51]. HiLog allows a form of higher-order programming, in which predicate ``symbols'' can be variable or structured. For example, definition and execution of generic predicates like this generic transitive closure relation are allowed:
closure(R)(X,Y) :- R(X,Y).
closure(R)(X,Y) :- R(X,Z), closure(R)(Z,Y).
where closure(R)/2 is (syntactically) a second-order predicate which, given any relation R, returns its transitive closure relation closure(R). XSB supports reading and writing of HiLog terms, converting them to or from internal format as necessary (see Section 4.2). Special meta-logical standard predicates (see Section 6.7) are also provided for inspection and handling of HiLog terms. Unlike earlier versions of XSB (prior to version 1.3.1) the current version automatically provides full compilation of HiLog predicates. As a result, most uses of HiLog execute at essentially the speed of compiled Prolog. For more information about the compilation scheme for HiLog employed in XSB see [51].

HiLog can also be used with tabling, so that the program above can also be written as:

:- hilog closure.
:- table apply/3.

closure(R)(X,Y) :- R(X,Y).
closure(R)(X,Y) :- closure(R)(X,Z), R(Z,Y).
as long as the underlying relations (the predicate symbols to which $R$ will be unified) are also declared as Hilog. For example, if a/2 were a binary relation to which the closure predicate would be applied, then the declaration :- hilog a. would also need to be included.


next up previous contents index
Next: 1.0.0.0.7 Unification Factoring Up: 1. Introduction Previous: 1.0.0.0.5 Fast Loading of   Contents   Index
Terrance Swift 2007-10-05