Пример #1
0
    def __init__(self, args, environment, logic, LOGICS=None, **options):
        Solver.__init__(self, environment, logic=logic)

        # Flag used to debug interaction with the solver
        self.dbg = False

        if LOGICS is not None: self.LOGICS = LOGICS
        self.args = args
        self.declared_vars = set()
        self.solver = Popen(args,
                            stdout=PIPE,
                            stderr=PIPE,
                            stdin=PIPE,
                            bufsize=-1)
        # Give time to the process to start-up
        time.sleep(0.01)
        self.parser = SmtLibParser(interactive=True)
        if PY2:
            self.solver_stdin = self.solver.stdin
            self.solver_stdout = self.solver.stdout
        else:
            self.solver_stdin = TextIOWrapper(self.solver.stdin)
            self.solver_stdout = TextIOWrapper(self.solver.stdout)

        # Initialize solver
        self.set_option(":print-success", "true")
        if self.options.generate_models:
            self.set_option(":produce-models", "true")
        # Redirect diagnostic output to stdout
        self.set_option(":diagnostic-output-channel", '"stdout"')
        self.set_logic(logic)
Пример #2
0
    def __init__(self, args, environment, logic, LOGICS=None, **options):
        Solver.__init__(self, environment, logic=logic, **options)
        self.to = self.environment.typeso
        if LOGICS is not None: self.LOGICS = LOGICS
        self.args = args
        self.declared_vars = [set()]
        self.declared_sorts = [set()]
        self.solver = Popen(args,
                            stdout=PIPE,
                            stderr=PIPE,
                            stdin=PIPE,
                            bufsize=-1)
        # Give time to the process to start-up
        time.sleep(0.01)
        self.parser = SmtLibParser(interactive=True)
        if PY2:
            self.solver_stdin = self.solver.stdin
            self.solver_stdout = self.solver.stdout
        else:
            self.solver_stdin = TextIOWrapper(self.solver.stdin)
            self.solver_stdout = TextIOWrapper(self.solver.stdout)

        # Initialize solver
        if options.get("produce_interpolants"):
            self.set_option(":produce-interpolants", "true")
        self.options(self)
        self.set_logic(logic)
Пример #3
0
    def __init__(self,
                 args,
                 environment,
                 logic,
                 user_options=None,
                 LOGICS=None):
        Solver.__init__(self,
                        environment,
                        logic=logic,
                        user_options=user_options)

        if LOGICS is not None: self.LOGICS = LOGICS
        self.args = args
        self.declared_vars = set()
        self.solver = Popen(args, stdout=PIPE, stderr=PIPE, stdin=PIPE)
        self.parser = SmtLibParser()
        if PY2:
            self.solver_stdin = self.solver.stdin
            self.solver_stdout = self.solver.stdout
        else:
            self.solver_stdin = TextIOWrapper(self.solver.stdin)
            self.solver_stdout = TextIOWrapper(self.solver.stdout)

        self.dbg = False

        # Initialize solver
        self._send_command(
            SmtLibCommand(smtcmd.SET_OPTION, [":print-success", "false"]))
        self._send_command(
            SmtLibCommand(smtcmd.SET_OPTION, [":produce-models", "true"]))

        if self.options is not None:
            for o, v in iteritems(self.options):
                self._send_command(SmtLibCommand(smtcmd.SET_OPTION, [o, v]))
        self._send_command(SmtLibCommand(smtcmd.SET_LOGIC, [logic]))
Пример #4
0
    def __init__(self, environment, logic, user_options):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        user_options=user_options)

        self.mgr = environment.formula_manager
        self.ddmanager = repycudd.DdManager()
        self.converter = BddConverter(environment=self.environment,
                                      ddmanager=self.ddmanager)

        # Impose initial ordering
        if self.options.static_ordering is not None:
            for var in self.options.static_ordering:
                if not var.is_symbol(types.BOOL):
                    raise ValueError("The BDD static ordering must be a " \
                                     "list of Boolean variables")
                self.declare_variable(var)

        if self.options.dynamic_reordering:
            self.ddmanager.AutodynEnable(self.options.reordering_algorithm)
        else:
            self.ddmanager.AutodynDisable()

        # This stack keeps a pair (Expr, Bdd), with the semantics that
        # the bdd at the i-th element of the list contains the bdd of
        # the conjunction of all previous expressions.
        # The construction of the Bdd is done during solve()
        self.assertions_stack = None
        self.reset_assertions() # Initialize the stack

        self.backtrack = []
        self.latest_model = None
Пример #5
0
    def __init__(self, args, environment, logic, user_options=None, LOGICS=None):
        Solver.__init__(self, environment, logic=logic, user_options=user_options)

        if LOGICS is not None:
            self.LOGICS = LOGICS
        self.args = args
        self.declared_vars = set()
        self.solver = Popen(args, stdout=PIPE, stderr=PIPE, stdin=PIPE)
        self.parser = SmtLibParser(interactive=True)
        if PY2:
            self.solver_stdin = self.solver.stdin
            self.solver_stdout = self.solver.stdout
        else:
            self.solver_stdin = TextIOWrapper(self.solver.stdin)
            self.solver_stdout = TextIOWrapper(self.solver.stdout)

        self.dbg = False

        # Initialize solver
        self._send_command(SmtLibCommand(smtcmd.SET_OPTION, [":print-success", "false"]))
        self._send_command(SmtLibCommand(smtcmd.SET_OPTION, [":produce-models", "true"]))

        if self.options is not None:
            for o, v in iteritems(self.options):
                self._send_command(SmtLibCommand(smtcmd.SET_OPTION, [o, v]))
        self._send_command(SmtLibCommand(smtcmd.SET_LOGIC, [logic]))
Пример #6
0
    def __init__(self, environment, logic, user_options):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        user_options=user_options)

        self.mgr = environment.formula_manager
        self.ddmanager = repycudd.DdManager()
        self.converter = BddConverter(environment=self.environment,
                                      ddmanager=self.ddmanager)

        # Impose initial ordering
        if self.options.static_ordering is not None:
            for var in self.options.static_ordering:
                if not var.is_symbol(types.BOOL):
                    raise ValueError("The BDD static ordering must be a " \
                                     "list of Boolean variables")
                self.declare_variable(var)

        if self.options.dynamic_reordering:
            self.ddmanager.AutodynEnable(self.options.reordering_algorithm)
        else:
            self.ddmanager.AutodynDisable()

        # This stack keeps a pair (Expr, Bdd), with the semantics that
        # the bdd at the i-th element of the list contains the bdd of
        # the conjunction of all previous expressions.
        # The construction of the Bdd is done during solve()
        self.assertions_stack = None
        self.reset_assertions()  # Initialize the stack

        self.backtrack = []
        self.latest_model = None
Пример #7
0
    def __init__(self, args, environment, logic, user_options=None,
                 LOGICS=None):
        Solver.__init__(self,
                        environment,
                        logic=logic,
                        user_options=user_options)
        # Flag used to debug interaction with the solver
        self.dbg = False

        if LOGICS is not None: self.LOGICS = LOGICS
        self.args = args
        self.declared_vars = set()
        self.solver = Popen(args, stdout=PIPE, stderr=PIPE, stdin=PIPE)
        self.parser = SmtLibParser(interactive=True)
        if PY2:
            self.solver_stdin = self.solver.stdin
            self.solver_stdout = self.solver.stdout
        else:
            self.solver_stdin = TextIOWrapper(self.solver.stdin)
            self.solver_stdout = TextIOWrapper(self.solver.stdout)

        # Initialize solver
        self.set_option(":print-success", "true")
        if self.options.generate_models:
            self.set_option(":produce-models", "true")
        # Redirect diagnostic output to stdout
        self.set_option(":diagnostic-output-channel", '"stdout"')
        if self.options is not None:
            for o,v in iteritems(self.options):
                self.set_option(o,v)
        self.set_logic(logic)
Пример #8
0
    def __init__(self, args, environment, logic, LOGICS=None, **options):
        Solver.__init__(self,
                        environment,
                        logic=logic,
                        **options)
        self.to = self.environment.typeso
        if LOGICS is not None: self.LOGICS = LOGICS
        self.args = args
        self.declared_vars = set()
        self.declared_sorts = set()
        self.solver = Popen(args, stdout=PIPE, stderr=PIPE, stdin=PIPE,
                            bufsize=-1)
        # Give time to the process to start-up
        time.sleep(0.01)
        self.parser = SmtLibParser(interactive=True)
        if PY2:
            self.solver_stdin = self.solver.stdin
            self.solver_stdout = self.solver.stdout
        else:
            self.solver_stdin = TextIOWrapper(self.solver.stdin)
            self.solver_stdout = TextIOWrapper(self.solver.stdout)

        # Initialize solver
        self.options(self)
        self.set_logic(logic)
Пример #9
0
    def __init__(self, environment, logic, **options):
        Solver.__init__(self, environment=environment, logic=logic, **options)

        self.mgr = environment.formula_manager
        self.pico = picosat.picosat_init()
        self.converter = None
        self.cnfizer = CNFizer(environment=environment)
        self.latest_model = None
        self._var_ids = {}
Пример #10
0
    def __init__(self, environment, logic, user_options):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        user_options=user_options)

        self.mgr = environment.formula_manager
        self.pico = picosat.picosat_init()
        self.converter = None
        self.cnfizer = CNFizer(environment=environment)
        self.latest_model = None
        self._var_ids = {}
Пример #11
0
    def __init__(self, environment, logic, **options):
        Solver.__init__(self, environment=environment, logic=logic, **options)

        self.declarations = set()

        self.yices = yicespy.yices_new_context(None)
        # MG: TODO: Set options!!!
        self.converter = YicesConverter(environment)
        self.mgr = environment.formula_manager
        self.model = None
        self.failed_pushes = 0
        return
Пример #12
0
    def __init__(self, environment, logic, user_options):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        user_options=user_options)

        self.declarations = set()

        self.yices = libyices.yices_new_context(None)
        self.converter = YicesConverter(environment)
        self.mgr = environment.formula_manager
        self.model = None
        return
Пример #13
0
    def __init__(self, environment, logic=None, options=None):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        options=options)

        self.declarations = set()

        self.yices = libyices.yices_new_context(None)
        self.converter = YicesConverter(environment)
        self.mgr = environment.formula_manager
        self.model = None
        return
Пример #14
0
    def __init__(self, environment, logic, options=None):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        options=options)
        # Here we could use:
        # self.z3 = z3.SolverFor(str(logic))
        # But it seems to have problems with quantified formulae
        self.z3 = z3.Solver()

        self.declarations = set()
        self.converter = Z3Converter(environment)
        self.mgr = environment.formula_manager
        return
Пример #15
0
    def __init__(self, environment, logic, **options):
        Solver.__init__(self, environment=environment, logic=logic, **options)
        self.em = CVC4.ExprManager()
        self.cvc4 = None
        self.declarations = None
        self.logic_name = str(logic)
        if self.logic_name == "QF_BOOL":
            self.logic_name = "QF_LRA"
        elif self.logic_name == "BOOL":
            self.logic_name = "LRA"

        self.reset_assertions()
        self.converter = CVC4Converter(environment, cvc4_exprMgr=self.em)
        return
Пример #16
0
    def __init__(self, environment, logic, **options):
        Solver.__init__(self, environment=environment, logic=logic, **options)
        self.em = CVC4.ExprManager()
        self.cvc4 = None
        self.declarations = None
        self.logic_name = str(logic)
        if self.logic_name == "QF_BOOL":
            self.logic_name = "QF_LRA"
        elif self.logic_name == "BOOL":
            self.logic_name = "LRA"

        self.reset_assertions()
        self.converter = CVC4Converter(environment, cvc4_exprMgr=self.em)
        return
Пример #17
0
    def __init__(self, environment, logic, **options):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        **options)

        self.declarations = set()

        self.yices = yicespy.yices_new_context(None)
        # MG: TODO: Set options!!!
        self.converter = YicesConverter(environment)
        self.mgr = environment.formula_manager
        self.model = None
        self.failed_pushes = 0
        return
Пример #18
0
    def __init__(self, environment, logic, **options):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        **options)

        self.mgr = environment.formula_manager
        self.pico = picosat.picosat_init()
        self.converter = None
        self.cnfizer = CNFizer(environment=environment)
        self.latest_model = None
        self._var_ids = {}
        self._log_file_handler = None
        # Initialize
        self.options(self)
Пример #19
0
    def __init__(self, environment, logic, options=None):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        options=options)
        self.em = CVC4.ExprManager()
        self.cvc4 = CVC4.SmtEngine(self.em)
        self.cvc4.setOption("produce-models", CVC4.SExpr("true"))

        logic_name = str(logic)
        if logic_name == "QF_BOOL":
            logic_name = "QF_LRA"
        self.cvc4.setLogic(logic_name)
        self.converter = CVC4Converter(environment, cvc4_exprMgr=self.em)
        self.declarations = set()
        return
Пример #20
0
    def __init__(self, environment, logic, user_options):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        user_options=user_options)
        self.em = CVC4.ExprManager()
        self.cvc4 = CVC4.SmtEngine(self.em)
        self.cvc4.setOption("produce-models", CVC4.SExpr("true"))

        self.logic_name = str(logic)
        if self.logic_name == "QF_BOOL":
            self.logic_name = "QF_LRA"
        self.cvc4.setLogic(self.logic_name)
        self.converter = CVC4Converter(environment, cvc4_exprMgr=self.em)
        self.declarations = set()
        return
Пример #21
0
    def __init__(self, environment, logic, **options):
        Solver.__init__(self, environment=environment, logic=logic, **options)

        self.declarations = set()
        self.yices_config = yicespy.yices_new_config()
        if yicespy.yices_default_config_for_logic(self.yices_config,
                                                  yices_logic(logic)) != 0:
            warn("Error setting config for logic %s" % logic)
        self.options(self)
        self.yices = yicespy.yices_new_context(self.yices_config)
        self.options.set_params(self)
        yicespy.yices_free_config(self.yices_config)
        self.converter = YicesConverter(environment)
        self.mgr = environment.formula_manager
        self.model = None
        self.failed_pushes = 0
        return
Пример #22
0
    def __init__(self, args, environment, logic, options=None):
        Solver.__init__(self, environment, logic=logic, options=options)

        self.args = args
        self.declared_vars = set()
        self.solver = Popen(args, stdout=PIPE, stderr=PIPE, stdin=PIPE)
        self.parser = SmtLibParser()
        self.dbg = False

        # Initialize solver
        self._send_command(
            SmtLibCommand(smtcmd.SET_OPTION, [":print-success", "false"]))
        self._send_command(
            SmtLibCommand(smtcmd.SET_OPTION, [":produce-models", "true"]))
        if options is not None:
            for o, v in iteritems(options):
                self._send_command(SmtLibCommand(smtcmd.SET_OPTION, [o, v]))
        self._send_command(SmtLibCommand(smtcmd.SET_LOGIC, [logic]))
Пример #23
0
    def __init__(self, environment, logic, **options):
        Solver.__init__(self, environment=environment, logic=logic, **options)

        self.mgr = environment.formula_manager
        self.ddmanager = repycudd.DdManager()
        self.converter = BddConverter(environment=self.environment,
                                      ddmanager=self.ddmanager)
        self.options(self)

        # This stack keeps a pair (Expr, Bdd), with the semantics that
        # the bdd at the i-th element of the list contains the bdd of
        # the conjunction of all previous expressions.
        # The construction of the Bdd is done during solve()
        self.assertions_stack = None
        self.reset_assertions()  # Initialize the stack

        self.backtrack = []
        self.latest_model = None
Пример #24
0
    def __init__(self, environment, logic, **options):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        **options)

        self.declarations = set()
        self.yices_config = yicespy.yices_new_config()
        if yicespy.yices_default_config_for_logic(self.yices_config,
                                                  yices_logic(logic)) != 0:
            warn("Error setting config for logic %s" % logic)
        self.options(self)
        self.yices = yicespy.yices_new_context(self.yices_config)
        self.options.set_params(self)
        yicespy.yices_free_config(self.yices_config)
        self.converter = YicesConverter(environment)
        self.mgr = environment.formula_manager
        self.model = None
        self.failed_pushes = 0
        return
Пример #25
0
    def __init__(self, environment, logic, **options):
        Solver.__init__(self, environment=environment, logic=logic, **options)
        self.em = CVC4.ExprManager()

        self.cvc4 = None
        self.declarations = None
        self.logic_name = str(logic)
        if "t" in self.logic_name:
            # Custom Type extension
            self.logic_name = self.logic_name.replace("t", "")
        if self.logic_name == "QF_BOOL":
            self.logic_name = "QF_LRA"
        elif self.logic_name == "BOOL":
            self.logic_name = "LRA"

        self.reset_assertions()
        self.converter = CVC4Converter(environment, cvc4_exprMgr=self.em)

        self.qf = False
        return
Пример #26
0
    def __init__(self, environment, logic, **options):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        **options)

        self.mgr = environment.formula_manager
        self.ddmanager = repycudd.DdManager()
        self.converter = BddConverter(environment=self.environment,
                                      ddmanager=self.ddmanager)
        self.options(self)

        # This stack keeps a pair (Expr, Bdd), with the semantics that
        # the bdd at the i-th element of the list contains the bdd of
        # the conjunction of all previous expressions.
        # The construction of the Bdd is done during solve()
        self.assertions_stack = None
        self.reset_assertions() # Initialize the stack

        self.backtrack = []
        self.latest_model = None
Пример #27
0
    def __init__(self, environment, logic, options=None, debugFile=None):
        Solver.__init__(self,
                        environment=environment,
                        logic=logic,
                        options=options)

        self.config = mathsat.msat_create_default_config(str(logic))
        check = mathsat.msat_set_option(self.config, "model_generation", "true")
        assert check == 0

        if debugFile is not None:
            mathsat.msat_set_option(self.config, "debug.api_call_trace", "1")
            mathsat.msat_set_option(self.config, "debug.api_call_trace_filename",
                                    debugFile)

        self.msat_env = mathsat.msat_create_env(self.config)

        self.realType = mathsat.msat_get_rational_type(self.msat_env)
        self.intType = mathsat.msat_get_integer_type(self.msat_env)
        self.boolType = mathsat.msat_get_bool_type(self.msat_env)

        self.mgr = environment.formula_manager
        self.converter = MSatConverter(environment, self.msat_env)
        return
Пример #28
0
    def __init__(self, args, environment, logic, LOGICS=None, **options):
        Solver.__init__(self, environment, logic=logic, **options)

        if LOGICS is not None: self.LOGICS = LOGICS
        self.args = args
        self.declared_vars = set()
        self.solver = Popen(args,
                            stdout=PIPE,
                            stderr=PIPE,
                            stdin=PIPE,
                            bufsize=-1)
        # Give time to the process to start-up
        time.sleep(0.01)
        self.parser = SmtLibParser(interactive=True)
        if PY2:
            self.solver_stdin = self.solver.stdin
            self.solver_stdout = self.solver.stdout
        else:
            self.solver_stdin = TextIOWrapper(self.solver.stdin)
            self.solver_stdout = TextIOWrapper(self.solver.stdout)

        # Initialize solver
        self.options(self)
        self.set_logic(logic)