1
votes

Is there a command that can be used in Sicstus Prolog that prints a list of built in predicates to the console window? Or something with a similar behaviour?

The following link suggests that a predicate apropos can be used to suggest predcicates based on a keyword, but this is for SWI-Prolog, no Sicstus.

http://www.swi-prolog.org/pldoc/doc_for?object=section%282%2C%27F.1%27%2Cswi%28%27%2Fdoc%2FManual%2Fpredsummary.html%27%29%29

2

2 Answers

3
votes

In SICStus Prolog, you can use the predicate_property/2 built-in predicate to list built-in predicates. For example:

| ?- predicate_property(P, built_in).
P = get_char(_A) ? ;
P = execution_state(_A) ? ;
...

If you want a list with all built-in predicates, try:

| ?- findall(P, predicate_property(P, built_in), L).
L = [get_char(_A),execution_state(_B),nospy _C,print_coverage(_D),print_profile(_E),debugging,disable_breakpoints(_F),current_breakpoint(_G,_H,_I,_J,_K),execution_state(_L,_M),spy(...)|...] ? 
yes
1
votes

current_predicate/1 is defined by ISO and seems to be available at least for SICSTUS, SWI-Prolog, and GNU-Prolog.

predicate_property/2 pointed out in the other answer is also available at least in these three Prolog implementations.

Note that for GNU-Prolog you would have to first turn off "strict_iso" if you want to enumerate built-ins with current_predicate/1:

| ?- current_predicate(P).

no
| ?- assertz(aaa).

yes
| ?- current_predicate(P).

P = aaa/0 ? ;

(1 ms) no
| ?- set_prolog_flag(strict_iso, off).

yes
| ?- current_predicate(P).            

P = max_list/2 ? ;

P = at_end_of_stream/0 ? ;

P = at_end_of_stream/1 ? % and so on