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
Example #2
0
File: tactics.py Project: asyaf/ivy
 def apply(self, goal):
     if ta.refuted_goal(goal):
         ta.remove_goal(goal)
         self.step(goal=goal, active=ta.top_goal())
         return True
     else:
         return False
 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):
     if ta.refuted_goal(goal):
         ta.remove_goal(goal)
         self.step(goal=goal, active=ta.top_goal())
         return True
     else:
         return False
Example #5
0
def render_proof_stack(proof_stack, node_events, node_actions):
    """
    Render a proof.ProofGoalStack object
    """
    g = CyElements()

    # add nodes
    for goal in proof_stack.stack:
        classes = ['proof_goal']
        short_info = "At ARG node {}".format(goal.node.id)
        if refuted_goal(goal):
            classes += ['refuted']
            short_info += ' (refuted)'
        long_info = [short_info, str(goal.formula)]
        g.add_node(
            obj=goal,
            label=str(goal.id),
            classes=classes,
            short_info=short_info,
            long_info=long_info,
            events=node_events,
            actions=node_actions(goal),
            locked=True,
        )

    # add edges
    for goal in proof_stack.stack:
        if goal.parent is not None:
            g.add_edge(
                'parent',
                goal,
                goal.parent,
                label='',
                classes=['proof_edge'],
                short_info='',
                long_info='',
                events=[],
                actions=[],
            )

    return g