current_predicate/2current_predicate(-Name, +Term)
current_predicate(*Name, *Term)
Unifies Name with the name of a user-defined predicate, and Term with the most general term corresponding to that predicate.
If you have loaded the predicates foo/1 and foo/3 into Prolog,
current_predicate/2 would return the following:
| ?- current_predicate(foo, T).
T = foo(_116) ;
T = foo(_116,_117,_118) ;
no
| ?- current_predicate(Name, Module:Term).
current_predicate/2 only succeeds for those predicates that are
defined in the module. It fails for those predicates that are imported
into a module.
| ?- current_predicate(_, m:P).
will backtrack through all predicates P that are defined in module m.
To backtrack through all predicates imported by a module use
predicate_property/2 (see ref-lps-ove).
To find out whether a predicate is built-in, use
predicate_property/2.
% Is there a callable predicate named gc?
| ?- current_predicate(gc, Term).
no
| ?- predicate_property(gc, Prop)
Prop = built_in
predicate_property/2