code: def extract_facts(rule):
      
      def _extract_facts(ce):
          if isinstance(ce, Fact):
              yield ce
          elif isinstance(ce, TEST):
              pass
          else:
              for e in ce:
                  yield from _extract_facts(e)
  
      return set(_extract_facts(rule))
docs: Given a rule, return a set containing all rule LHS facts.