def _try_rewrite_staticfunction(s,l,t): condizioni = t[2][:] funcImpl = t[1] need_resolution = [ ( issubclass(x, Variable) or issubclass(x, Function)) for (x,_) in condizioni] #print condizioni #print need_resolution if not True in need_resolution : # prima ad eseguire l'operazione direttamente from icse.predicates.Eq import Eq return (Eq, funcImpl.sign()['handler'](*[x for (_,x) in condizioni])) else: return (Function.withFunction(t[1]), condizioni)
if __name__ == '__main__': rete = ReteNetwork() ''' (defrule r1 (A =(+ 1 1) B) => ) ''' p = Production(name="r1:", lhs=[ (PositivePredicate, [(Eq, 'A'), (Variable, 'var')]), (PositivePredicate, [(Eq, 'A'), (Function.withFunction(Addition), [(Eq, 1), (Variable, 'var')]), (Eq, "B")]), ], rhs=[ (Printout, ["t", (Variable, 'A'), "il mio testo", "crlf"]) ], description="" ) rete.add_production(p) rete.assert_fact(['A', 1]) rete.assert_fact(['A', 2,'B']) rete.assert_fact(['A', 1,'B'])