def extract_proof( proof_log: deephol_pb2.ProofLog) -> Optional[deephol_pb2.ProofLog]: """Reduce the proof into a simply checkable format. The utility of this function is to prune the proof to an acyclic sub-hypergraph, so that the proof argument is trivial to check. All the nodes in this acyclic hypergraph are proved and correspond to the proof of the root node of the proof log. The nodes are ordered from the higherst level targets, that means each goals precede their subgoals in the list of nodes. Args: proof_log: The proof_log that needs to be reduced. Returns: A new ProofLog with a mimimal proof necessary to prove all closed Theorem nodes. """ if not proof_log.nodes: return proof_log result = find_reasons(proof_log) if result is None: return None (reasons, _) = result new_log = deephol_pb2.ProofLog( error_message=proof_log.error_message, num_proofs=proof_log.num_proofs, prover_options=proof_log.prover_options, time_spent=proof_log.time_spent, theorem_in_database=proof_log.theorem_in_database) new_log.nodes.extend([ _keep_tac_app(proof_log.nodes[node_index], tac_app_index) for node_index, tac_app_index, _ in reasons ]) return new_log
def to_proto(self) -> deephol_pb2.ProofLog: """Serialize the proof search tree as a protobuf. Returns: A deephol_pb2.ProofLog protobuf representing the whole proof search tree. """ proof_log = deephol_pb2.ProofLog() for node in self.nodes: status = deephol_pb2.ProofNode.UNKNOWN if node.closed: status = deephol_pb2.ProofNode.PROVED node_log = proof_log.nodes.add( goal=node.goal, status=status, action_generation_time_millisec=node. action_generation_time_millisec) for tapp in node.failed_attempts: tapp.add_to_node_proto(node_log) for tapp in node.successful_attempts: tapp.add_to_node_proto(node_log) return proof_log
def make_empty_log(error_message: Text): return deephol_pb2.ProofLog(error_message=error_message, num_proofs=0, prover_options=prover_options)
def new_log(num_proofs: int = 1, time_spent: int = 10000): """Create a new proof log.""" return deephol_pb2.ProofLog(num_proofs=num_proofs, prover_options=deephol_pb2.ProverOptions(), time_spent=time_spent)