Prolog Texts

Prolog texts have the syntax of a consult text, see section 4.3. When consulted the contained facts and rules are asserted. The encountered head predicates of the facts and rules are declared static by default. Further any directives in the theory text are executed in the order they appear. These directives might additionally declare foreign predicates. Upon consulting again a source, the related declared predicates are first abolished.

The consult performs various style checks. The facts and rules are checked for singleton variables. Singleton variables need to be input in the form of anonymous variables (_). The facts and rules for the same head predicate need to form one block. The directive discontiguous/1 allows exempting a predicate from this style check.  The special file name user can be used to consult from the standard input.

Normally the facts and rules for the same head predicate come from one source only. The directive multifile/1 allows exempting a predicate from this style check. Multi-file predicates behave differently during re-consult. If a declared predicate spans multiple sources only the clauses belonging to the re-consulted source are retracted. The defined predicate will only be abolished when it does not belong to any source anymore.

The following theory files predicates are provided:
ensure_loaded(R): [ISO 7.4.2.8]
The predicate ensures that the relative source path R is loaded. If the current time is after the expiration of the source then it will connect to the source. If the source was not modified since its last modified then it will consult the source.
consult(R):
First retract the old facts and rules of the relative source path R. Then assert the new facts and rules from the relative source path R. During assert also process the directives from the relative source path R. Before assert the scope is temporarily changed to the relative source path R.
unload_file(R):
Detach the source identified by the relative source path R.
[S1, ..., Sm]:
The predicate processes the path specifications S1, ..., Sm. The following path specifications are recognized:
+R: Ensure load the relative path R.
-R: Detach the relative path R.
R: Consult the relative path R.
make:
The predicate ensures that all used sources are loaded.
rebuild:
The predicate consults all used sources.
include(R): [ISO 7.4.2.7]
Doesn’t retract the old facts and rules of the relative source path R. Asserts the new facts and rules from the relative source path R. Processes the directives from the relative source path R. Doesn’t change the scope to the relative source path R.
discontiguous I, ...: [ISO 7.4.2.3]
The predicate sets the predicate indicator I to discontinuous.
multifile I, ...: [ISO 7.4.2.2]
The predicate sets the predicate indicator I to multi-file.
listing:
The predicate lists the user clauses of the user syntax operators, evaluable functions and predicates. Only non-automatic evaluable functions and predicates are listed.
listing(I):
The predicate lists the user clauses of the user syntax operators, evaluable functions and predicates that match the pattern I. Only non-automatic evaluable functions and predicates are listed.

The following Prolog flags for theory files are provided:

sys_last_pred:
The value is a predicate indicator or null. The value indicates the head predicate of the recently consulted clause. The value can be changed.
sys_timeout:
The value is a positive 64-bit integer. The value determines the wait before source locks timeout during loading. The value is measured in milliseconds. The value can be changed.
verbose:
The value can be one of the atoms off, summary, details or on. The value indicates the verbosity level for the loading and unloading of files. The summary level shows a count of the loaded and unloaded files. The details level shows each loaded or unloaded file names. The on level shows both, details followed by summary.

The following predicate properties for theory files are provided:

sys_usage(S):
The property indicates that the defined predicate has definitions in the source context S. The property is multi valued or can be missing. The property cannot directly be changed.
discontiguous(S):
The property indicates that the predicate has been marked discontinuous in the source context S. The property is multi valued and can be missing.
multifile:
The property indicates that predicate is multi-file.
sys_multifile(S):
The property indicates that the predicate has been marked multi-file in source context S. The property is multi valued and can be missing. The property can be changed.

The following syntax operator properties for theory files are provided:

sys_usage(S):
The syntax operator property indicates that the defined operator has definitions in the source context S. The property is single valued or can be missing. The property cannot directly be changed.

The following theory files operators are provided:

H :- B:
The construct defines a Prolog rule with head H and body B.

Comments