def test_action_generator_theorem_list_parameter_tactic( self, use_embedding_store): """Checks max_theorem_parameters parameters are passed for a thmlist tactic. Args: use_embedding_store: True if the embedding store should be used. """ max_parameters = self.options.max_theorem_parameters emb_store = None thmlist_param_tactic = deephol_pb2.Tactic( name='TAC', parameter_types=[deephol_pb2.Tactic.THEOREM_LIST]) dummy_theorem = proof_assistant_pb2.Theorem(name='THM', conclusion='foo') theorem_database = proof_assistant_pb2.TheoremDatabase() theorem_database.theorems.extend([ proof_assistant_pb2.Theorem(name='THM%d' % i, conclusion='foo') for i in range(2 * max_parameters + 1) ]) if use_embedding_store: emb_store = embedding_store.TheoremEmbeddingStore(self.predictor) emb_store.compute_embeddings_for_thms_from_db(theorem_database) action_gen = action_generator.ActionGenerator( theorem_database, [thmlist_param_tactic], self.predictor, self.options, self.model_architecture, emb_store) test_theorem = theorem_database.theorems[2 * max_parameters] actions_scores = action_gen.step( self.node, prover_util.make_premise_set(test_theorem, 'default')) self.assertStartsWith(actions_scores[-1].string, 'TAC') self.assertEqual(max_parameters, actions_scores[-1].string.count('THM'))
def setUpClass(cls): """Restoring the graph takes a lot of memory, so we do it only once here.""" cls.predictor = holparam_predictor.HolparamPredictor( PREDICTIONS_MODEL_PREFIX) cls.model_architecture = deephol_pb2.ProverOptions.PAIR_DEFAULT cls.theorem_database = proof_assistant_pb2.TheoremDatabase() cls.theorem_database.theorems.add(name='EQ_REFL', conclusion=EQ_REFL) cls.theorem_database.theorems.add(name='EQ_SYM', conclusion=EQ_SYM) cls.test_goal_index = 1 cls.test_theorem = cls.theorem_database.theorems[cls.test_goal_index] cls.test_goal = cls.theorem_database.theorems[cls.test_goal_index] cls.test_premise_set = prover_util.make_premise_set( cls.test_theorem, 'default') cls.options = deephol_pb2.ActionGeneratorOptions()
def mock_generator(*tactic_scores): return MockActionGenerator([ action_generator.Suggestion(string=tactic, score=score) for tactic, score in tactic_scores ]) MOCK_WRAPPER = MockHolLightWrapper() MOCK_THEOREM = proof_assistant_pb2.Theorem( name='TH1', hypotheses=['h'], conclusion='c', tag=proof_assistant_pb2.Theorem.THEOREM, training_split=proof_assistant_pb2.Theorem.TESTING) MOCK_PREMISE_SET = prover_util.make_premise_set(MOCK_THEOREM, 'default') class ProverUtilTest(tf.test.TestCase): def setUp(self): tf.logging.info('Setting up tree...') self.tree = proof_search_tree.ProofSearchTree(MOCK_WRAPPER, MOCK_THEOREM) def test_create_initial_tree(self): tree = self.tree self.assertEqual(len(tree.nodes), 1) self.assertEqual(len(tree.nodes_map), 1) def test_node(node): self.assertEqual(node.index, 0)