mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 09:05:31 +00:00
fixing problems
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
8744b26d06
commit
847c5f9691
6 changed files with 66 additions and 29 deletions
|
@ -47,10 +47,21 @@ namespace smt {
|
|||
|
||||
void qi_queue::setup() {
|
||||
TRACE("qi_cost", tout << "qi_cost: " << m_params.m_qi_cost << "\n";);
|
||||
if (!m_parser.parse_string(m_params.m_qi_cost.c_str(), m_cost_function))
|
||||
throw default_exception("invalid cost function %s", m_params.m_qi_cost.c_str());
|
||||
if (!m_parser.parse_string(m_params.m_qi_new_gen.c_str(), m_new_gen_function))
|
||||
throw default_exception("invalid new-gen function %s", m_params.m_qi_new_gen.c_str());
|
||||
if (!m_parser.parse_string(m_params.m_qi_cost.c_str(), m_cost_function)) {
|
||||
// it is not reasonable to abort here during the creation of smt::context just because an invalid option was provided.
|
||||
// throw default_exception("invalid cost function %s", m_params.m_qi_cost.c_str());
|
||||
|
||||
// using warning message instead
|
||||
warning_msg("invalid cost function '%s', switching to default one", m_params.m_qi_cost.c_str());
|
||||
// Trying again with default function
|
||||
VERIFY(m_parser.parse_string("(+ weight generation)", m_cost_function));
|
||||
}
|
||||
if (!m_parser.parse_string(m_params.m_qi_new_gen.c_str(), m_new_gen_function)) {
|
||||
// See comment above
|
||||
// throw default_exception("invalid new-gen function %s", m_params.m_qi_new_gen.c_str());
|
||||
warning_msg("invalid new_gen function '%s', switching to default one", m_params.m_qi_new_gen.c_str());
|
||||
VERIFY(m_parser.parse_string("cost", m_new_gen_function));
|
||||
}
|
||||
m_eager_cost_threshold = m_params.m_qi_eager_threshold;
|
||||
}
|
||||
|
||||
|
|
|
@ -56,9 +56,13 @@ namespace smt {
|
|||
|
||||
virtual void init_core(ast_manager & m, symbol const & logic) {
|
||||
reset();
|
||||
#pragma omp critical (solver)
|
||||
// We can throw exceptions when creating a smt::kernel object
|
||||
// So, we should create the smt::kernel outside of the criticial section
|
||||
// block. OMP does not allow exceptions to cross critical section boundaries.
|
||||
smt::kernel * new_kernel = alloc(smt::kernel, m, m_params);
|
||||
#pragma omp critical (solver)
|
||||
{
|
||||
m_context = alloc(smt::kernel, m, m_params);
|
||||
m_context = new_kernel;
|
||||
if (m_callback)
|
||||
m_context->set_progress_callback(m_callback);
|
||||
}
|
||||
|
@ -77,59 +81,67 @@ namespace smt {
|
|||
|
||||
virtual void reset_core() {
|
||||
if (m_context != 0) {
|
||||
#pragma omp critical (solver)
|
||||
#pragma omp critical (solver)
|
||||
{
|
||||
dealloc(m_context);
|
||||
m_context = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// An exception may be thrown when creating a smt::kernel.
|
||||
// So, there is no guarantee that m_context != 0 when
|
||||
// using smt_solver from the SMT 2.0 command line frontend.
|
||||
void check_context() const {
|
||||
if (m_context == 0)
|
||||
throw default_exception("Z3 failed to create solver, check previous error messages");
|
||||
}
|
||||
|
||||
virtual void assert_expr(expr * t) {
|
||||
SASSERT(m_context);
|
||||
check_context();
|
||||
m_context->assert_expr(t);
|
||||
}
|
||||
|
||||
virtual void push_core() {
|
||||
SASSERT(m_context);
|
||||
check_context();
|
||||
m_context->push();
|
||||
}
|
||||
|
||||
virtual void pop_core(unsigned n) {
|
||||
SASSERT(m_context);
|
||||
check_context();
|
||||
m_context->pop(n);
|
||||
}
|
||||
|
||||
virtual lbool check_sat_core(unsigned num_assumptions, expr * const * assumptions) {
|
||||
SASSERT(m_context);
|
||||
check_context();
|
||||
TRACE("solver_na2as", tout << "smt_solver::check_sat_core: " << num_assumptions << "\n";);
|
||||
return m_context->check(num_assumptions, assumptions);
|
||||
}
|
||||
|
||||
virtual void get_unsat_core(ptr_vector<expr> & r) {
|
||||
SASSERT(m_context);
|
||||
check_context();
|
||||
unsigned sz = m_context->get_unsat_core_size();
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
r.push_back(m_context->get_unsat_core_expr(i));
|
||||
}
|
||||
|
||||
virtual void get_model(model_ref & m) {
|
||||
SASSERT(m_context);
|
||||
check_context();
|
||||
m_context->get_model(m);
|
||||
}
|
||||
|
||||
virtual proof * get_proof() {
|
||||
SASSERT(m_context);
|
||||
check_context();
|
||||
return m_context->get_proof();
|
||||
}
|
||||
|
||||
virtual std::string reason_unknown() const {
|
||||
SASSERT(m_context);
|
||||
check_context();
|
||||
return m_context->last_failure_as_string();
|
||||
}
|
||||
|
||||
virtual void get_labels(svector<symbol> & r) {
|
||||
SASSERT(m_context);
|
||||
check_context();
|
||||
buffer<symbol> tmp;
|
||||
m_context->get_relevant_labels(0, tmp);
|
||||
r.append(tmp.size(), tmp.c_ptr());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue