Module provable

For debugging purposes it might be necessary to access predicates and evaluable functions that are not accessible from the top-level by the module system visibility rules. We provide predicates that allow direct access. The access is call-site independent, requires structured module names with package prefixes resolved and the module already loaded.

Examples:
?- current_predicate(basic/lists:member2/3).
No
?- current_provable(basic/lists:member2/3).
Yes

The directly accessible predicates can be tested and enumerated by the predicate current_provable/1. The predicates provable_property/2, set_provable_property/2 and reset_provable_property/2 are responsible for accessing and modifying properties of directly accessible predicates.

Example:
?- length(X, 0), callable_property(X, Y), writeq(Y), nl, fail; true.
sys_context('<path>/lists.px')
source_file('<path>/lists.px')
line_no(136)
Yes

Context and pretty printing information of an atom can be accessed and modified by the predicates callable_property/2, set_callable_property/3 and reset_callable_property/3. The predicates defined here generalize the predicates sys_get_context/2 and sys_replace_site/3 from the Jekejeke Prolog runtime.

The following provable access predicates are supported:
current_provable(P):
The predicate succeeds for the directly accessible predicates P.
provable_property(I, Q):
The predicate succeeds for the properties Q of the predicate I. The predicate will also try to access invisible predicates.
set_provable_property(I, Q):
The predicate assigns the property Q to the predicate I. The predicate will also try to access invisible predicates.
reset_provable_property(I, Q):
The predicate de-assigns the property Q from the predicate I. The predicate will also try to access invisible predicates.
callable_property(A, Q):
The predicate succeeds for the properties Q of the callable A.
set_callable_property(B, Q, A):
The predicate succeeds for a new callable B which is a clone of the callable A except for the property Q which is now set.
reset_callable_property(B, Q, A):
The predicate succeeds for a new atom B which is a clone of the callable A except for the property Q which is now reset.

The following callable properties are provided:

source_file(O):
The property indicates that the callable has the file origin O associated. The property is single valued and can be missing. The property cannot be changed.
line_no(L):
The property indicates that the callable has the line number L. The property is single valued and can be missing. The property cannot be changed.
sys_context(S):
The property indicates that this callable has the module source S associated. The property is single valued and might be missing.
sys_hint(H):
The property indicates that this callable has the hint H associated. The property is single valued and might be missing.
sys_fillers(F):
The property indicates that this callable has the fillers F associated. The property is multi valued and might be missing.

Comments