Suppose I have a facts db filled with at least:
fact1(A) :- !, A=ok.
fact2(B) :- !, B=ok.
How can I enumerate through all the facts in this db? Ideally I’d have a predicate that I could use:
?- all_rules( Head :- Tail).
Head=fact1(_G100),
Tail=(!, _G100=ok) ;
Head=fact2(_G101),
Tail=(!, _G101=ok)
....followed by all other predicates in other modules loaded...
I found current_predicate/1, but I can’t figure out what this is actually doing…
It depends on the precise Prolog system you are using. As long, as you only want to look at the definitions,
listing/0works in many systems. Butlisting/0only prints a text.clause/2often works only for predicates declared dynamically.