Exemple #1
0
    def smtlib_solver(self, stream):
        smt_parser = SmtLibParser()
        name = self.args.solver
        if name == "auto":
            solver = Solver()
        else:
            solver = Solver(name=name)

        for cmd in smt_parser.get_command_generator(stream):
            r = evaluate_command(cmd, solver)
            self.print_result(cmd, r)
Exemple #2
0
    def smtlib_solver(self, stream):
        smt_parser = SmtLibParser()
        name = self.args.solver
        if name == "auto":
            solver = Solver()
        else:
            solver = Solver(name=name)

        for cmd in smt_parser.get_command_generator(stream):
            r = evaluate_command(cmd, solver)
            self.print_result(cmd, r)
Exemple #3
0
    def test_all_parsing(self):
        # Create a small file that tests all commands of smt-lib 2
        parser = SmtLibParser()

        nie = 0
        for cmd in DEMO_SMTSCRIPT:
            try:
                next(parser.get_command_generator(cStringIO(cmd)))
            except NotImplementedError:
                nie += 1
        # There are currently 3 not-implemented commands
        self.assertEqual(nie, 3)
Exemple #4
0
    def test_all_parsing(self):
        # Create a small file that tests all commands of smt-lib 2
        parser = SmtLibParser()

        nie = 0
        for cmd in DEMO_SMTSCRIPT:
            try:
                next(parser.get_command_generator(cStringIO(cmd)))
            except NotImplementedError:
                nie += 1
        # There are currently 3 not-implemented commands
        self.assertEquals(nie, 3)
Exemple #5
0
    def _recover_declarations(self, data):
        decls = {'consts': {}, 'funs': {}}

        parser = SmtLibParser()
        parser._reset()
        script = SmtLibScript()
        try:
            for cmd in parser.get_command_generator(cStringIO(data)):
                script.add_command(cmd)
        except RuntimeError:
            # Oblivious hack to prevent oop pysmt-related error
            pass
        script.annotations = parser.cache.annotations
        symbol_decls = script.filter_by_command_name('declare-fun')
        self._recover_declared_symbols(symbol_decls, decls)
        symbol_decls = script.filter_by_command_name('declare-const')
        self._recover_declared_symbols(symbol_decls, decls)
        asserts = script.filter_by_command_name('assert')
        self._prune_unused_symbols(asserts, decls)

        return decls