<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def extract_facts(rule):
 """Given a rule, return a set containing all rule LHS facts."""

    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))