Example #1
0
File: tactics.py Project: asyaf/ivy
 def apply(self, goal, x, y, auto_remove=True):
     info = dict(goal=goal, x=x, y=y)
     if x:
         ta.arg_add_facts(goal.node, y)
         removed = []
         removed_str = []
         if auto_remove:
             g = goal
             while g is not None and ta.refuted_goal(g):
                 removed.append(g)
                 removed_str.append(str(g))
                 ta.remove_goal(g)
                 g = g.parent
             info['removed'] = removed
             if g is not None:
                 info['active'] = g
             else:
                 info['active'] = goal.node
         info['msg'] = dedent("""
         Learned new fact at arg node {}:
         {}
         Removed goals: {}
         """).strip().format(
             goal.node.id,
             y,
             ', '.join(removed_str),
         )
     else:
         ta.push_goal(y)
         info['active'] = y
         info['msg'] = dedent("""
         No refinement for goal {}, pushed new goal {}
         """).strip().format(goal, y)
     self.step(**info)
     return x
 def apply(self, goal, x, y, auto_remove=True):
     info = dict(goal=goal, x=x, y=y)
     if x:
         ta.arg_add_facts(goal.node, y)
         removed = []
         removed_str = []
         if auto_remove:
             g = goal
             while g is not None and ta.refuted_goal(g):
                 removed.append(g)
                 removed_str.append(str(g))
                 ta.remove_goal(g)
                 g = g.parent
             info['removed'] = removed
             if g is not None:
                 info['active'] = g
             else:
                 info['active'] = goal.node
         info['msg'] = dedent("""
         Learned new fact at arg node {}:
         {}
         Removed goals: {}
         """).strip().format(
             goal.node.id,
             y,
             ', '.join(removed_str),
         )
     else:
         ta.push_goal(y)
         info['active'] = y
         info['msg'] = dedent("""
         No refinement for goal {}, pushed new goal {}
         """).strip().format(goal, y)
     self.step(**info)
     return x
 def apply(self, node, facts):
     preds, action = ta.arg_get_preds_action(node)
     assert action != 'join'
     assert len(preds) == 1
     pred = preds[0]
     already_implied = ta.implied_facts(arg_get_fact(node), facts)
     implied = ta.implied_facts(
         forward_image(arg_get_fact(pred), action),
         list(set(facts) - set(already_implied)),
     )
     if len(implied) > 0:
         for fact in implied:
             ta.arg_add_facts(node, fact)
         self.step(node=node, facts=facts, implied=implied)
         return True
     else:
         return False
Example #4
0
File: tactics.py Project: asyaf/ivy
 def apply(self, node, facts):
     preds, action = ta.arg_get_preds_action(node)
     assert action != 'join'
     assert len(preds) == 1
     pred = preds[0]
     already_implied = ta.implied_facts(
         arg_get_fact(node),
         facts
     )
     implied = ta.implied_facts(
         forward_image(arg_get_fact(pred), action),
         list(set(facts) - set(already_implied)),
     )
     if len(implied) > 0:
         for fact in implied:
             ta.arg_add_facts(node, fact)
         self.step(node=node, facts=facts, implied=implied)
         return True
     else:
         return False