def solve(self): self._send_command("(check-sat)") ans = self._get_answer() if ans == "sat": return True elif ans == "unsat": return False elif ans == "unknown": raise SolverReturnedUnknownResultError else: raise UnknownSolverAnswerError("Solver returned: " + ans)
def solve(self, assumptions=None): assert assumptions is None self._send_command(SmtLibCommand(smtcmd.CHECK_SAT, [])) ans = self._get_answer() if ans == "sat": return True elif ans == "unsat": return False elif ans == "unknown": raise SolverReturnedUnknownResultError else: raise UnknownSolverAnswerError("Solver returned: " + ans)
def sequence_interpolant(self, formulas): """Returns a sequence interpolant for the conjunction of formulas, or None if the problem is satisfiable. """ solver = SmtLibSolver(self.options[0], self.options[1], self.options[2], self.options[3], **self.options[4]) for f in formulas: sorts = solver.to.get_types(f, custom_only=True) for s in sorts: if all(s not in ds for ds in solver.declared_sorts): solver._declare_sort(s) deps = f.get_free_variables() for d in deps: if all(d not in dv for dv in solver.declared_vars): solver._declare_variable(d) names = [] i = 0 for f in formulas: self._send_named_assert_command(f, "IP_%d" % i, solver) names.append("IP_%d" % i) i += 1 solver._send_command(SmtLibCommand(smtcmd.CHECK_SAT, [])) ans = solver._get_answer() if ans == "sat": return None elif ans == "unsat": pass elif ans == "unknown": raise SolverReturnedUnknownResultError else: raise UnknownSolverAnswerError("Solver returned: " + ans) solver._send_command(SmtLibCommand(smtcmd.GET_INTERPOLANTS, names)) res = solver.parser.get_interpolant_list(solver.solver_stdout) solver._exit() return res
def _check_success(self): res = self._get_answer() if res != "success": raise UnknownSolverAnswerError("Solver returned: '%s'" % res)