def get_named_unsat_core(self): """After a call to solve() yielding UNSAT, returns the unsat core as a dict of names to formulae""" if self.options.unsat_cores_mode is None: raise SolverNotConfiguredForUnsatCoresError if self.last_result is not False: raise SolverStatusError("The last call to solve() was not" \ " unsatisfiable") if self.last_command != "solve": raise SolverStatusError("The solver status has been modified by a" \ " '%s' command after the last call to" \ " solve()" % self.last_command) assumptions = self.z3.unsat_core() pysmt_assumptions = set(self.converter.back(t) for t in assumptions) res = {} n_ass_map = self._named_assertions_map() cnt = 0 for key in pysmt_assumptions: if key in n_ass_map: (name, formula) = n_ass_map[key] if name is None: name = "_a_%d" % cnt cnt += 1 res[name] = formula return res
def _check_unsat_core_config(self): if self.options.unsat_cores_mode is None: raise SolverNotConfiguredForUnsatCoresError if self.last_result is None or self.last_result: raise SolverStatusError("The last call to solve() was not" \ " unsatisfiable") if self.last_command != "solve": raise SolverStatusError("The solver status has been modified by a" \ " '%s' command after the last call to" \ " solve()" % self.last_command)
def get_named_unsat_core(self): """After a call to solve() yielding UNSAT, returns the unsat core as a dict of names to formulae""" if self.options.unsat_cores_mode is None: raise SolverNotConfiguredForUnsatCoresError if self.last_result is not False: raise SolverStatusError("The last call to solve() was not" \ " unsatisfiable") if self.last_command != "solve": raise SolverStatusError("The solver status has been modified by a" \ " '%s' command after the last call to" \ " solve()" % self.last_command) assumptions = yicespy.term_vector_t() yicespy.yices_init_term_vector(assumptions) code = yicespy.yices_get_unsat_core(self.yices, assumptions) if code != 0: msg = yicespy.yices_error_string() raise InternalSolverError("Yices returned non-zero code upon unsat core extraction"\ ": %s (code: %s)" % \ (msg, code)) # for i in range(assumptions.size): # d = assumptions.data[i] # print(yicespy.yices_term_to_string(d, 200, 10, 0)) pysmt_assumptions = set(self.converter.back(assumptions.data[i]) for i in range(assumptions.size)) yicespy.yices_delete_term_vector(assumptions) res = {} n_ass_map = self._named_assertions_map() cnt = 0 for key in pysmt_assumptions: if key in n_ass_map: (name, formula) = n_ass_map[key] if name is None: name = "_a_%d" % cnt cnt += 1 res[name] = formula return res
def solve_error(*args, **kwargs): raise SolverStatusError( "Cannot call is_sat twice when incrementality is disable")