Пример #1
0
 def setUp(self):
     self.tac0 = deephol_pb2.Tactic(id=0, name="TAC0")
     self.tac1 = deephol_pb2.Tactic(id=1, name="TAC1")
     self.tac1r = deephol_pb2.Tactic(id=1, name="TAC1r")
     self.tac2 = deephol_pb2.Tactic(id=2, name="TAC2")
     self.tactics_info = deephol_pb2.TacticsInfo()
     self.replacements = deephol_pb2.TacticsInfo()
Пример #2
0
    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'))
Пример #3
0
 def test_action_generator_unknown_parameter_tactic(self):
     unknown_param_tactic = deephol_pb2.Tactic(
         name='TAC', parameter_types=[deephol_pb2.Tactic.UNKNOWN])
     action_gen = action_generator.ActionGenerator(self.theorem_database,
                                                   [unknown_param_tactic],
                                                   self.predictor,
                                                   self.options,
                                                   self.model_architecture)
     actions_scores = action_gen.step(self.node, self.test_premise_set)
     self.assertEqual(0, len(actions_scores))
Пример #4
0
 def test_action_generator_no_parameter_tactic(self):
     no_param_tactic = deephol_pb2.Tactic(name='TAC')
     action_gen = action_generator.ActionGenerator(self.theorem_database,
                                                   [no_param_tactic],
                                                   self.predictor,
                                                   self.options,
                                                   self.model_architecture)
     actions_scores = action_gen.step(self.node, self.test_premise_set)
     self.assertEqual(1, len(actions_scores))
     self.assertEqual(actions_scores[0].string, 'TAC')
Пример #5
0
 def test_action_generator_theorem_parameter_tactic(self):
     thm_param_tactic = deephol_pb2.Tactic(
         name='TAC', parameter_types=[deephol_pb2.Tactic.THEOREM])
     action_gen = action_generator.ActionGenerator(self.theorem_database,
                                                   [thm_param_tactic],
                                                   self.predictor,
                                                   self.options,
                                                   self.model_architecture)
     actions_scores = action_gen.step(self.node, self.test_premise_set)
     self.assertEqual(1, len(actions_scores))
     expected = 'TAC ' + theorem_fingerprint.ToTacticArgument(
         self.theorem_database.theorems[0])
     self.assertEqual(expected, actions_scores[0].string)