#NEWLINE# def get_relevant_facts( proposition , assumptions = ( True , ) , context = global_assumptions , use_known_facts = True , exprs = None , relevant_facts = None ) : #NEWLINE# #INDENT# newexprs = set ( ) #NEWLINE# if ( not exprs ) : #NEWLINE# #INDENT# keys = proposition . atoms ( AppliedPredicate ) #NEWLINE# keys |= Tuple ( * assumptions ) . atoms ( AppliedPredicate ) #NEWLINE# if context : #NEWLINE# #INDENT# keys |= And ( * context ) . atoms ( AppliedPredicate ) #NEWLINE# #UNINDENT# exprs = { key . args [ 0 ] for key in keys } #NEWLINE# #UNINDENT# if ( not relevant_facts ) : #NEWLINE# #INDENT# relevant_facts = set ( [ ] ) #NEWLINE# #UNINDENT# if use_known_facts : #NEWLINE# #INDENT# for expr in exprs : #NEWLINE# #INDENT# relevant_facts . add ( get_known_facts_cnf ( ) . rcall ( expr ) ) #NEWLINE# #UNINDENT# #UNINDENT# for expr in exprs : #NEWLINE# #INDENT# for fact in fact_registry [ expr . func ] : #NEWLINE# #INDENT# newfact = fact . rcall ( expr ) #NEWLINE# relevant_facts . add ( newfact ) #NEWLINE# newexprs |= set ( [ key . args [ 0 ] for key in newfact . atoms ( AppliedPredicate ) ] ) #NEWLINE# #UNINDENT# #UNINDENT# return ( relevant_facts , ( newexprs - exprs ) )