title: How to find all prolog rules in database
body: <p>Suppose I have a facts db filled with at least:</p>
  
  <pre><code>fact1(A) :- !, A=ok.
  fact2(B) :- !, B=ok.
  </code></pre>
  
  <p>How can I enumerate through all the facts in this db?  Ideally I'd have a predicate that I could use:</p>
  
  <pre><code>?- 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...
  </code></pre>
  
  <p>I found <a href="http://www.swi-prolog.org/pldoc/doc_for?object=current_predicate/1" rel="noreferrer">current_predicate/1</a>, but I can't figure out what this is actually doing...</p>