4.11.13.2 Predicates Visible in a Module

The built-in predicate predicate_property/2 can be used to find the properties of any predicate that is visible to a particular module.

To backtrack through all of the predicates imported by module m, use

     | ?- predicate_property(m:Goal, imported_from(_)).

To backtrack through all of the predicates imported by module m1 from module m2, use

     | ?- predicate_property(m1:Goal, imported_from(m2)).

For example, you can load the basics module from the library and then remind yourself of what predicates it defines like this:

     | ?- compile(library(basics)).
     % ... loading messages ...
     
     yes
     | ?- predicate_property(P, imported_from(basics)).
     
     P = member(_2497,_2498) ;
     P = memberchk(_2497,_2498) ;
       .
       .
       .

This tells you what predicates are imported into the type-in module from basics.

You can also find all imports into all modules using

     | ?- predicate_property(M1:G, imported_from(M2)).

To backtrack through all of the predicates exported by module m, use

     | ?- predicate_property(m:Goal, exported).

Send feedback on this subject.