Ejemplo n.º 1
0
 def test_root_has_simple_proof_order2(self):
     proof_log = proof_test_util.new_log(num_proofs=1)
     proof_test_util.add_node(proof_log, [[]], True)
     proof_test_util.add_node(proof_log, [[0]], True, True)
     reasons, nodes = proof_analysis.find_reasons(proof_log)
     self.assertEqual(nodes, [1, 0])
     self.assertEqual(reasons, [(1, 0, [0]), (0, 0, [])])
Ejemplo n.º 2
0
 def test_multi_root_has_simple_proof(self):
     proof_log = proof_test_util.new_log(num_proofs=1)
     proof_test_util.add_node(proof_log, [[2]], True, True)
     proof_test_util.add_node(proof_log, [[2]], True, True)
     proof_test_util.add_node(proof_log, [[]], True)
     reasons, nodes = proof_analysis.find_reasons(proof_log)
     self.assertEqual(nodes, [0, 1, 2])
     self.assertEqual(reasons, [(0, 0, [2]), (1, 0, [2]), (2, 0, [])])
Ejemplo n.º 3
0
 def test_root_has_chain_ignores_unclosed(self):
     proof_log = proof_test_util.new_log(num_proofs=1)
     proof_test_util.add_node(proof_log, [[1]], True, True)
     proof_test_util.add_node(proof_log, [[2]], True)
     proof_test_util.add_node(proof_log, [[5], [4]], True)
     proof_test_util.add_node(proof_log, [[]], True)
     proof_test_util.add_node(proof_log, [[]], True)
     proof_test_util.add_node(proof_log, [], True)
     reasons, nodes = proof_analysis.find_reasons(proof_log)
     self.assertEqual(nodes, [0, 1, 2, 4])
     self.assertEqual(reasons, [(0, 0, [1]), (1, 0, [2]), (2, 1, [4]),
                                (4, 0, [])])
Ejemplo n.º 4
0
 def test_root_has_chain_ignores_loop_order2(self):
     proof_log = proof_test_util.new_log(num_proofs=1)
     proof_test_util.add_node(proof_log, [], True)
     proof_test_util.add_node(proof_log, [[2]], True, True)
     proof_test_util.add_node(proof_log, [[3]], True)
     proof_test_util.add_node(proof_log, [[2], [5]], True)
     proof_test_util.add_node(proof_log, [[]], True)
     proof_test_util.add_node(proof_log, [[]], True)
     reasons, nodes = proof_analysis.find_reasons(proof_log)
     self.assertEqual(nodes, [1, 2, 3, 5])
     self.assertEqual(reasons, [(1, 0, [2]), (2, 0, [3]), (3, 1, [5]),
                                (5, 0, [])])
Ejemplo n.º 5
0
def proof_log_stats(
        proof_log: deephol_pb2.ProofLog) -> deephol_stat_pb2.ProofStat:
    """Create statistics for a single proof log."""
    num_attempted = 0
    num_proved = 0
    num_bad_proofs = 0
    closed_node_indices = []
    fingerprint = None
    reduced_node_indices = []
    for i, node in enumerate(proof_log.nodes):
        if node.goal.tag == proof_assistant_pb2.Theorem.THEOREM:
            num_attempted += 1
            if node.status == deephol_pb2.ProofNode.PROVED:
                num_proved += 1
            if fingerprint is None:
                fingerprint = theorem_fingerprint.Fingerprint(node.goal)
        if node.status == deephol_pb2.ProofNode.PROVED:
            closed_node_indices.append(i)
    if num_proved > 0:
        analysis_result = proof_analysis.find_reasons(proof_log)
        if analysis_result is None:
            num_bad_proofs += 1
            num_proved = 0
        else:
            _, reduced_node_indices = analysis_result
    stat = deephol_stat_pb2.ProofStat(
        num_theorems_attempted=num_attempted,
        num_theorems_proved=num_proved,
        num_theorems_with_bad_proof=num_bad_proofs,
        num_nodes=len(proof_log.nodes),
        reduced_node_indices=reduced_node_indices,
        closed_node_indices=closed_node_indices)
    if proof_log.HasField('time_spent'):
        stat.time_spent_milliseconds = proof_log.time_spent
    if num_attempted == 1 and fingerprint is not None:
        stat.theorem_fingerprint = fingerprint

    for node in proof_log.nodes:
        stat.total_prediction_time += node.action_generation_time_millisec
        add_value_to_log_scale_histogram(stat.node_prediction_time_histogram,
                                         node.action_generation_time_millisec,
                                         1)
        for tapp in node.proofs:
            tactic_application_stats(stat.tapp_stat, tapp)

    return stat
Ejemplo n.º 6
0
 def test_root_is_leaf(self):
     proof_log = proof_test_util.new_log(num_proofs=1)
     proof_test_util.add_node(proof_log, [[]], True, True)
     reasons, nodes = proof_analysis.find_reasons(proof_log)
     self.assertEqual(nodes, [0])
     self.assertEqual(reasons, [(0, 0, [])])
Ejemplo n.º 7
0
 def test_root_invalid_simple_proof(self):
     proof_log = proof_test_util.new_log(num_proofs=0)
     proof_test_util.add_node(proof_log, [[1]], True, True)
     proof_test_util.add_node(proof_log, [], False)
     self.assertIsNone(proof_analysis.find_reasons(proof_log))
Ejemplo n.º 8
0
 def test_root_no_reasons(self):
     proof_log = proof_test_util.new_log(num_proofs=0)
     proof_test_util.add_node(proof_log, [], True, True)
     self.assertIsNone(proof_analysis.find_reasons(proof_log))
Ejemplo n.º 9
0
 def test_root_not_marked(self):
     proof_log = proof_test_util.new_log(num_proofs=0)
     proof_test_util.add_node(proof_log, [], False, False)
     self.assertEqual(proof_analysis.find_reasons(proof_log), ([], []))
Ejemplo n.º 10
0
 def test_empty_log_reasons(self):
     proof_log = proof_test_util.new_log(num_proofs=0)
     self.assertEqual(proof_analysis.find_reasons(proof_log), ([], []))