mirror of
https://github.com/Z3Prover/z3
synced 2025-05-05 06:45:45 +00:00
old_params ==> front_end_params. Isolated abstract solver interface
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
62cc752fb6
commit
4c98b567e1
60 changed files with 491 additions and 295 deletions
|
@ -27,6 +27,7 @@ Notes:
|
|||
#include"cmd_util.h"
|
||||
#include"simplify_cmd.h"
|
||||
#include"eval_cmd.h"
|
||||
#include"front_end_params.h"
|
||||
|
||||
class help_cmd : public cmd {
|
||||
svector<symbol> m_cmds;
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
check_sat_result.h
|
||||
|
||||
Abstract:
|
||||
Abstract interface for storing the result produced by
|
||||
a check_sat like command
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2012-01-23
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _CHECK_SAT_RESULT_H_
|
||||
#define _CHECK_SAT_RESULT_H_
|
||||
|
||||
#include"model.h"
|
||||
#include"lbool.h"
|
||||
#include"statistics.h"
|
||||
|
||||
class check_sat_result {
|
||||
protected:
|
||||
unsigned m_ref_count;
|
||||
lbool m_status;
|
||||
public:
|
||||
check_sat_result():m_ref_count(0), m_status(l_undef) {}
|
||||
virtual ~check_sat_result() {}
|
||||
void inc_ref() { m_ref_count++; }
|
||||
void dec_ref() { SASSERT(m_ref_count > 0); m_ref_count--; if (m_ref_count == 0) dealloc(this); }
|
||||
void set_status(lbool r) { m_status = r; }
|
||||
lbool status() const { return m_status; }
|
||||
virtual void collect_statistics(statistics & st) const = 0;
|
||||
virtual void get_unsat_core(ptr_vector<expr> & r) = 0;
|
||||
virtual void get_model(model_ref & m) = 0;
|
||||
virtual proof * get_proof() = 0;
|
||||
virtual std::string reason_unknown() const = 0;
|
||||
virtual void get_labels(svector<symbol> & r) = 0;
|
||||
};
|
||||
|
||||
struct simple_check_sat_result : public check_sat_result {
|
||||
statistics m_stats;
|
||||
model_ref m_model;
|
||||
expr_ref_vector m_core;
|
||||
proof_ref m_proof;
|
||||
std::string m_unknown;
|
||||
|
||||
simple_check_sat_result(ast_manager & m):
|
||||
m_core(m),
|
||||
m_proof(m) {
|
||||
}
|
||||
virtual ~simple_check_sat_result() {}
|
||||
virtual void collect_statistics(statistics & st) const { st.copy(m_stats); }
|
||||
virtual void get_unsat_core(ptr_vector<expr> & r) { if (m_status == l_false) r.append(m_core.size(), m_core.c_ptr()); }
|
||||
virtual void get_model(model_ref & m) {
|
||||
if (m_status != l_false) m = m_model; else m = 0;
|
||||
}
|
||||
virtual proof * get_proof() { return m_status == l_false ? m_proof.get() : 0; }
|
||||
virtual std::string reason_unknown() const {
|
||||
return m_unknown;
|
||||
}
|
||||
virtual void get_labels(svector<symbol> & r) {}
|
||||
};
|
||||
|
||||
#endif
|
|
@ -348,6 +348,18 @@ cmd_context::~cmd_context() {
|
|||
}
|
||||
}
|
||||
|
||||
bool cmd_context::is_smtlib2_compliant() const {
|
||||
return params().m_smtlib2_compliant;
|
||||
}
|
||||
|
||||
bool cmd_context::produce_models() const {
|
||||
return params().m_model;
|
||||
}
|
||||
|
||||
bool cmd_context::produce_proofs() const {
|
||||
return params().m_proof_mode != PGM_DISABLED;
|
||||
}
|
||||
|
||||
cmd_context::check_sat_state cmd_context::cs_state() const {
|
||||
if (m_check_sat_result.get() == 0)
|
||||
return css_clear;
|
||||
|
|
|
@ -249,7 +249,7 @@ protected:
|
|||
public:
|
||||
cmd_context(front_end_params * params = 0, bool main_ctx = true, ast_manager * m = 0, symbol const & l = symbol::null);
|
||||
~cmd_context();
|
||||
bool is_smtlib2_compliant() const { return params().m_smtlib2_compliant; }
|
||||
bool is_smtlib2_compliant() const;
|
||||
void set_logic(symbol const & s);
|
||||
bool has_logic() const { return m_logic != symbol::null; }
|
||||
symbol const & get_logic() const { return m_logic; }
|
||||
|
@ -269,8 +269,8 @@ public:
|
|||
void set_global_decls(bool flag) { SASSERT(!has_manager()); m_global_decls = flag; }
|
||||
unsigned random_seed() const { return m_random_seed; }
|
||||
void set_random_seed(unsigned s) { m_random_seed = s; }
|
||||
bool produce_models() const { return params().m_model; }
|
||||
bool produce_proofs() const { return params().m_proof_mode != PGM_DISABLED; }
|
||||
bool produce_models() const;
|
||||
bool produce_proofs() const;
|
||||
bool produce_unsat_cores() const { return m_produce_unsat_cores; }
|
||||
void set_produce_unsat_cores(bool flag) { m_produce_unsat_cores = flag; }
|
||||
bool produce_assignments() const { return m_produce_assignments; }
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/*++
|
||||
Copyright (c) 2008 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
progress_callback.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Virtual callback for reporting progress.
|
||||
|
||||
Author:
|
||||
|
||||
Michal Moskal (micmo) 2009-02-17.
|
||||
|
||||
Revision History:
|
||||
|
||||
--*/
|
||||
#ifndef _PROGRESS_CALLBACK_H_
|
||||
#define _PROGRESS_CALLBACK_H_
|
||||
|
||||
class progress_callback {
|
||||
public:
|
||||
virtual ~progress_callback() {}
|
||||
|
||||
// Called approx. every m_progress_sampling_freq miliseconds
|
||||
virtual void slow_progress_sample() { }
|
||||
|
||||
// Called on every check for reqsource limit exceeded (mach more frequent).
|
||||
virtual void fast_progress_sample() { }
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,34 +0,0 @@
|
|||
/*++
|
||||
Copyright (c) 2011 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
solver.h
|
||||
|
||||
Abstract:
|
||||
|
||||
abstract solver interface
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2011-03-19
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#include"solver.h"
|
||||
|
||||
unsigned solver::get_num_assertions() const {
|
||||
NOT_IMPLEMENTED_YET();
|
||||
return 0;
|
||||
}
|
||||
|
||||
expr * solver::get_assertion(unsigned idx) const {
|
||||
NOT_IMPLEMENTED_YET();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void solver::display(std::ostream & out) const {
|
||||
out << "(solver)";
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/*++
|
||||
Copyright (c) 2011 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
solver.h
|
||||
|
||||
Abstract:
|
||||
|
||||
abstract solver interface
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2011-03-19
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _SOLVER_H_
|
||||
#define _SOLVER_H_
|
||||
|
||||
#include"check_sat_result.h"
|
||||
#include"front_end_params.h"
|
||||
#include"progress_callback.h"
|
||||
#include"params.h"
|
||||
|
||||
class solver : public check_sat_result {
|
||||
public:
|
||||
virtual ~solver() {}
|
||||
|
||||
// for backward compatibility
|
||||
virtual void set_front_end_params(front_end_params & p) {}
|
||||
|
||||
virtual void updt_params(params_ref const & p) {}
|
||||
virtual void collect_param_descrs(param_descrs & r) {}
|
||||
|
||||
virtual void set_produce_proofs(bool f) {}
|
||||
virtual void set_produce_models(bool f) {}
|
||||
virtual void set_produce_unsat_cores(bool f) {}
|
||||
|
||||
virtual void init(ast_manager & m, symbol const & logic) = 0;
|
||||
virtual void reset() = 0;
|
||||
virtual void assert_expr(expr * t) = 0;
|
||||
virtual void push() = 0;
|
||||
virtual void pop(unsigned n) = 0;
|
||||
virtual unsigned get_scope_level() const = 0;
|
||||
virtual lbool check_sat(unsigned num_assumptions, expr * const * assumptions) = 0;
|
||||
|
||||
virtual void set_cancel(bool f) {}
|
||||
void cancel() { set_cancel(true); }
|
||||
void reset_cancel() { set_cancel(false); }
|
||||
|
||||
virtual void set_progress_callback(progress_callback * callback) = 0;
|
||||
|
||||
virtual unsigned get_num_assertions() const;
|
||||
virtual expr * get_assertion(unsigned idx) const;
|
||||
|
||||
virtual void display(std::ostream & out) const;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,485 +0,0 @@
|
|||
/*++
|
||||
Copyright (c) 2011 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
strategic_solver.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Strategies -> Solver
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2011-05-19
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#include"strategic_solver.h"
|
||||
#include"cmd_context.h"
|
||||
#include"scoped_timer.h"
|
||||
#include"params2front_end_params.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
|
||||
// minimum verbosity level for portfolio verbose messages
|
||||
#define PS_VB_LVL 15
|
||||
|
||||
strategic_solver::strategic_solver():
|
||||
m_manager(0),
|
||||
m_fparams(0),
|
||||
m_force_tactic(false),
|
||||
m_inc_mode(false),
|
||||
m_check_sat_executed(false),
|
||||
m_inc_solver(0),
|
||||
m_inc_solver_timeout(UINT_MAX),
|
||||
m_inc_unknown_behavior(IUB_USE_TACTIC_IF_QF),
|
||||
m_default_fct(0),
|
||||
m_curr_tactic(0),
|
||||
m_proof(0),
|
||||
m_callback(0) {
|
||||
m_use_inc_solver_results = false;
|
||||
DEBUG_CODE(m_num_scopes = 0;);
|
||||
m_produce_proofs = false;
|
||||
m_produce_models = false;
|
||||
m_produce_unsat_cores = false;
|
||||
}
|
||||
|
||||
strategic_solver::~strategic_solver() {
|
||||
SASSERT(!m_curr_tactic);
|
||||
dictionary<tactic_factory*>::iterator it = m_logic2fct.begin();
|
||||
dictionary<tactic_factory*>::iterator end = m_logic2fct.end();
|
||||
for (; it != end; ++it) {
|
||||
dealloc(it->m_value);
|
||||
}
|
||||
if (m_proof)
|
||||
m().dec_ref(m_proof);
|
||||
}
|
||||
|
||||
bool strategic_solver::has_quantifiers() const {
|
||||
unsigned sz = get_num_assertions();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
if (::has_quantifiers(get_assertion(i)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Return true if a tactic should be used when the incremental solver returns unknown.
|
||||
*/
|
||||
bool strategic_solver::use_tactic_when_undef() const {
|
||||
switch (m_inc_unknown_behavior) {
|
||||
case IUB_RETURN_UNDEF: return false;
|
||||
case IUB_USE_TACTIC_IF_QF: return !has_quantifiers();
|
||||
case IUB_USE_TACTIC: return true;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void strategic_solver::set_inc_solver(solver * s) {
|
||||
SASSERT(m_inc_solver == 0);
|
||||
SASSERT(m_num_scopes == 0);
|
||||
m_inc_solver = s;
|
||||
if (m_callback)
|
||||
m_inc_solver->set_progress_callback(m_callback);
|
||||
}
|
||||
|
||||
void strategic_solver::updt_params(params_ref const & p) {
|
||||
if (m_inc_solver)
|
||||
m_inc_solver->updt_params(p);
|
||||
if (m_fparams)
|
||||
params2front_end_params(p, *m_fparams);
|
||||
}
|
||||
|
||||
|
||||
void strategic_solver::collect_param_descrs(param_descrs & r) {
|
||||
if (m_inc_solver)
|
||||
m_inc_solver->collect_param_descrs(r);
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Set a timeout for each check_sat query that is processed by the inc_solver.
|
||||
timeout == UINT_MAX means infinite
|
||||
After the timeout a strategy is used.
|
||||
*/
|
||||
void strategic_solver::set_inc_solver_timeout(unsigned timeout) {
|
||||
m_inc_solver_timeout = timeout;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Set the default tactic factory.
|
||||
It is used if there is no tactic for a given logic.
|
||||
*/
|
||||
void strategic_solver::set_default_tactic(tactic_factory * fct) {
|
||||
m_default_fct = fct;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Set a tactic factory for a given logic.
|
||||
*/
|
||||
void strategic_solver::set_tactic_for(symbol const & logic, tactic_factory * fct) {
|
||||
tactic_factory * old_fct;
|
||||
if (m_logic2fct.find(logic, old_fct)) {
|
||||
dealloc(old_fct);
|
||||
}
|
||||
m_logic2fct.insert(logic, fct);
|
||||
}
|
||||
|
||||
void strategic_solver::init(ast_manager & m, symbol const & logic) {
|
||||
m_manager = &m;
|
||||
m_logic = logic;
|
||||
if (m_inc_mode) {
|
||||
SASSERT(m_inc_solver);
|
||||
m_inc_solver->init(m, logic);
|
||||
}
|
||||
}
|
||||
|
||||
// delayed inc solver initialization
|
||||
void strategic_solver::init_inc_solver() {
|
||||
if (m_inc_mode)
|
||||
return; // solver was already initialized
|
||||
if (!m_inc_solver)
|
||||
return; // inc solver was not installed
|
||||
m_inc_mode = true;
|
||||
m_inc_solver->set_front_end_params(*m_fparams);
|
||||
m_inc_solver->init(m(), m_logic);
|
||||
unsigned sz = get_num_assertions();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
m_inc_solver->assert_expr(get_assertion(i));
|
||||
}
|
||||
}
|
||||
|
||||
void strategic_solver::collect_statistics(statistics & st) const {
|
||||
if (m_use_inc_solver_results) {
|
||||
SASSERT(m_inc_solver);
|
||||
m_inc_solver->collect_statistics(st);
|
||||
}
|
||||
else {
|
||||
if (m_curr_tactic)
|
||||
m_curr_tactic->collect_statistics(st); // m_curr_tactic is still being executed.
|
||||
else
|
||||
st.copy(m_stats);
|
||||
}
|
||||
}
|
||||
|
||||
void strategic_solver::reset() {
|
||||
m_logic = symbol::null;
|
||||
m_inc_mode = false;
|
||||
m_check_sat_executed = false;
|
||||
if (m_inc_solver)
|
||||
m_inc_solver->reset();
|
||||
SASSERT(!m_curr_tactic);
|
||||
m_use_inc_solver_results = false;
|
||||
reset_results();
|
||||
}
|
||||
|
||||
void strategic_solver::reset_results() {
|
||||
m_use_inc_solver_results = false;
|
||||
m_model = 0;
|
||||
if (m_proof) {
|
||||
m().dec_ref(m_proof);
|
||||
m_proof = 0;
|
||||
}
|
||||
m_reason_unknown.clear();
|
||||
m_stats.reset();
|
||||
}
|
||||
|
||||
void strategic_solver::assert_expr(expr * t) {
|
||||
if (m_check_sat_executed && !m_inc_mode) {
|
||||
// a check sat was already executed --> switch to incremental mode
|
||||
init_inc_solver();
|
||||
SASSERT(m_inc_solver == 0 || m_inc_mode);
|
||||
}
|
||||
if (m_inc_mode) {
|
||||
SASSERT(m_inc_solver);
|
||||
m_inc_solver->assert_expr(t);
|
||||
}
|
||||
}
|
||||
|
||||
void strategic_solver::push() {
|
||||
DEBUG_CODE(m_num_scopes++;);
|
||||
init_inc_solver();
|
||||
if (m_inc_solver)
|
||||
m_inc_solver->push();
|
||||
}
|
||||
|
||||
void strategic_solver::pop(unsigned n) {
|
||||
DEBUG_CODE({
|
||||
SASSERT(n <= m_num_scopes);
|
||||
m_num_scopes -= n;
|
||||
});
|
||||
init_inc_solver();
|
||||
if (m_inc_solver)
|
||||
m_inc_solver->pop(n);
|
||||
}
|
||||
|
||||
unsigned strategic_solver::get_scope_level() const {
|
||||
if (m_inc_solver)
|
||||
return m_inc_solver->get_scope_level();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct aux_timeout_eh : public event_handler {
|
||||
solver * m_solver;
|
||||
volatile bool m_canceled;
|
||||
aux_timeout_eh(solver * s):m_solver(s), m_canceled(false) {}
|
||||
virtual void operator()() {
|
||||
m_solver->cancel();
|
||||
m_canceled = true;
|
||||
}
|
||||
};
|
||||
|
||||
struct strategic_solver::mk_tactic {
|
||||
strategic_solver * m_solver;
|
||||
|
||||
mk_tactic(strategic_solver * s, tactic_factory * f):m_solver(s) {
|
||||
ast_manager & m = s->m();
|
||||
params_ref p;
|
||||
front_end_params2params(*s->m_fparams, p);
|
||||
tactic * tct = (*f)(m, p);
|
||||
tct->set_front_end_params(*s->m_fparams);
|
||||
tct->set_logic(s->m_logic);
|
||||
if (s->m_callback)
|
||||
tct->set_progress_callback(s->m_callback);
|
||||
#pragma omp critical (strategic_solver)
|
||||
{
|
||||
s->m_curr_tactic = tct;
|
||||
}
|
||||
}
|
||||
|
||||
~mk_tactic() {
|
||||
#pragma omp critical (strategic_solver)
|
||||
{
|
||||
m_solver->m_curr_tactic = 0;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
tactic_factory * strategic_solver::get_tactic_factory() const {
|
||||
tactic_factory * f = 0;
|
||||
if (m_logic2fct.find(m_logic, f))
|
||||
return f;
|
||||
return m_default_fct.get();
|
||||
}
|
||||
|
||||
lbool strategic_solver::check_sat_with_assumptions(unsigned num_assumptions, expr * const * assumptions) {
|
||||
if (!m_inc_solver) {
|
||||
IF_VERBOSE(PS_VB_LVL, verbose_stream() << "incremental solver was not installed, returning unknown...\n";);
|
||||
m_use_inc_solver_results = false;
|
||||
m_reason_unknown = "incomplete";
|
||||
return l_undef;
|
||||
}
|
||||
init_inc_solver();
|
||||
m_use_inc_solver_results = true;
|
||||
return m_inc_solver->check_sat(num_assumptions, assumptions);
|
||||
}
|
||||
|
||||
lbool strategic_solver::check_sat(unsigned num_assumptions, expr * const * assumptions) {
|
||||
reset_results();
|
||||
m_check_sat_executed = true;
|
||||
if (num_assumptions > 0 || // assumptions were provided
|
||||
(!m_fparams->m_auto_config && !m_force_tactic) // auto config and force_tactic are turned off
|
||||
) {
|
||||
// must use incremental solver
|
||||
return check_sat_with_assumptions(num_assumptions, assumptions);
|
||||
}
|
||||
|
||||
tactic_factory * factory = get_tactic_factory();
|
||||
if (factory == 0)
|
||||
init_inc_solver(); // try to switch to incremental solver
|
||||
|
||||
if (m_inc_mode) {
|
||||
SASSERT(m_inc_solver);
|
||||
unsigned timeout = m_inc_solver_timeout;
|
||||
if (factory == 0)
|
||||
timeout = UINT_MAX; // there is no tactic available
|
||||
if (timeout == UINT_MAX) {
|
||||
IF_VERBOSE(PS_VB_LVL, verbose_stream() << "using incremental solver (without a timeout).\n";);
|
||||
m_use_inc_solver_results = true;
|
||||
lbool r = m_inc_solver->check_sat(0, 0);
|
||||
if (r != l_undef || factory == 0 || !use_tactic_when_undef()) {
|
||||
m_use_inc_solver_results = true;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
else {
|
||||
IF_VERBOSE(PS_VB_LVL, verbose_stream() << "using incremental solver (with timeout).\n";);
|
||||
SASSERT(factory != 0);
|
||||
aux_timeout_eh eh(m_inc_solver.get());
|
||||
lbool r;
|
||||
{
|
||||
scoped_timer timer(m_inc_solver_timeout, &eh);
|
||||
r = m_inc_solver->check_sat(0, 0);
|
||||
}
|
||||
if ((r != l_undef || !use_tactic_when_undef()) && !eh.m_canceled) {
|
||||
m_use_inc_solver_results = true;
|
||||
return r;
|
||||
}
|
||||
}
|
||||
IF_VERBOSE(PS_VB_LVL, verbose_stream() << "incremental solver failed, trying tactic.\n";);
|
||||
}
|
||||
|
||||
m_use_inc_solver_results = false;
|
||||
|
||||
if (factory == 0) {
|
||||
IF_VERBOSE(PS_VB_LVL, verbose_stream() << "there is no tactic available for the current logic.\n";);
|
||||
m_reason_unknown = "incomplete";
|
||||
return l_undef;
|
||||
}
|
||||
|
||||
goal_ref g = alloc(goal, m(), m_produce_proofs, m_produce_models, m_produce_unsat_cores);
|
||||
unsigned sz = get_num_assertions();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
g->assert_expr(get_assertion(i));
|
||||
}
|
||||
expr_dependency_ref core(m());
|
||||
|
||||
mk_tactic tct_maker(this, factory);
|
||||
SASSERT(m_curr_tactic);
|
||||
|
||||
proof_ref pr(m());
|
||||
lbool r = ::check_sat(*(m_curr_tactic.get()), g, m_model, pr, core, m_reason_unknown);
|
||||
m_curr_tactic->collect_statistics(m_stats);
|
||||
if (pr) {
|
||||
m_proof = pr;
|
||||
m().inc_ref(m_proof);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
void strategic_solver::set_cancel(bool f) {
|
||||
if (m_inc_solver)
|
||||
m_inc_solver->set_cancel(f);
|
||||
#pragma omp critical (strategic_solver)
|
||||
{
|
||||
if (m_curr_tactic)
|
||||
m_curr_tactic->set_cancel(f);
|
||||
}
|
||||
}
|
||||
|
||||
void strategic_solver::get_unsat_core(ptr_vector<expr> & r) {
|
||||
if (m_use_inc_solver_results) {
|
||||
SASSERT(m_inc_solver);
|
||||
m_inc_solver->get_unsat_core(r);
|
||||
}
|
||||
}
|
||||
|
||||
void strategic_solver::get_model(model_ref & m) {
|
||||
if (m_use_inc_solver_results) {
|
||||
SASSERT(m_inc_solver);
|
||||
m_inc_solver->get_model(m);
|
||||
}
|
||||
else {
|
||||
m = m_model;
|
||||
}
|
||||
}
|
||||
|
||||
proof * strategic_solver::get_proof() {
|
||||
if (m_use_inc_solver_results) {
|
||||
SASSERT(m_inc_solver);
|
||||
return m_inc_solver->get_proof();
|
||||
}
|
||||
else {
|
||||
return m_proof;
|
||||
}
|
||||
}
|
||||
|
||||
std::string strategic_solver::reason_unknown() const {
|
||||
if (m_use_inc_solver_results) {
|
||||
SASSERT(m_inc_solver);
|
||||
return m_inc_solver->reason_unknown();
|
||||
}
|
||||
return m_reason_unknown;
|
||||
}
|
||||
|
||||
void strategic_solver::get_labels(svector<symbol> & r) {
|
||||
if (m_use_inc_solver_results) {
|
||||
SASSERT(m_inc_solver);
|
||||
m_inc_solver->get_labels(r);
|
||||
}
|
||||
}
|
||||
|
||||
void strategic_solver::set_progress_callback(progress_callback * callback) {
|
||||
m_callback = callback;
|
||||
if (m_inc_solver)
|
||||
m_inc_solver->set_progress_callback(callback);
|
||||
}
|
||||
|
||||
void strategic_solver::display(std::ostream & out) const {
|
||||
if (m_manager) {
|
||||
unsigned num = get_num_assertions();
|
||||
out << "(solver";
|
||||
for (unsigned i = 0; i < num; i++) {
|
||||
out << "\n " << mk_ismt2_pp(get_assertion(i), m(), 2);
|
||||
}
|
||||
out << ")";
|
||||
}
|
||||
else {
|
||||
out << "(solver)";
|
||||
}
|
||||
}
|
||||
|
||||
strategic_solver_cmd::strategic_solver_cmd(cmd_context & ctx):
|
||||
m_ctx(ctx) {
|
||||
}
|
||||
|
||||
unsigned strategic_solver_cmd::get_num_assertions() const {
|
||||
return static_cast<unsigned>(m_ctx.end_assertions() - m_ctx.begin_assertions());
|
||||
}
|
||||
|
||||
expr * strategic_solver_cmd::get_assertion(unsigned idx) const {
|
||||
SASSERT(idx < get_num_assertions());
|
||||
return m_ctx.begin_assertions()[idx];
|
||||
}
|
||||
|
||||
strategic_solver_api::ctx::ctx(ast_manager & m):m_assertions(m) {
|
||||
}
|
||||
|
||||
void strategic_solver_api::init(ast_manager & m, symbol const & logic) {
|
||||
strategic_solver::init(m, logic);
|
||||
m_ctx = alloc(ctx, m);
|
||||
}
|
||||
|
||||
unsigned strategic_solver_api::get_num_assertions() const {
|
||||
if (m_ctx == 0)
|
||||
return 0;
|
||||
return m_ctx->m_assertions.size();
|
||||
}
|
||||
|
||||
expr * strategic_solver_api::get_assertion(unsigned idx) const {
|
||||
SASSERT(m_ctx);
|
||||
return m_ctx->m_assertions.get(idx);
|
||||
}
|
||||
|
||||
void strategic_solver_api::assert_expr(expr * t) {
|
||||
SASSERT(m_ctx);
|
||||
strategic_solver::assert_expr(t);
|
||||
m_ctx->m_assertions.push_back(t);
|
||||
}
|
||||
|
||||
void strategic_solver_api::push() {
|
||||
SASSERT(m_ctx);
|
||||
strategic_solver::push();
|
||||
m_ctx->m_scopes.push_back(m_ctx->m_assertions.size());
|
||||
}
|
||||
|
||||
void strategic_solver_api::pop(unsigned n) {
|
||||
SASSERT(m_ctx);
|
||||
unsigned new_lvl = m_ctx->m_scopes.size() - n;
|
||||
unsigned old_sz = m_ctx->m_scopes[new_lvl];
|
||||
m_ctx->m_assertions.shrink(old_sz);
|
||||
m_ctx->m_scopes.shrink(new_lvl);
|
||||
strategic_solver::pop(n);
|
||||
}
|
||||
|
||||
void strategic_solver_api::reset() {
|
||||
m_ctx = 0;
|
||||
strategic_solver::reset();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
/*++
|
||||
Copyright (c) 2011 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
strategic_solver.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Strategies -> Solver
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2011-05-19
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _STRATEGIC_SOLVER_H_
|
||||
#define _STRATEGIC_SOLVER_H_
|
||||
|
||||
#include"solver.h"
|
||||
#include"tactic.h"
|
||||
|
||||
class progress_callback;
|
||||
struct front_end_params;
|
||||
|
||||
class strategic_solver : public solver {
|
||||
public:
|
||||
// Behavior when the incremental solver returns unknown.
|
||||
enum inc_unknown_behavior {
|
||||
IUB_RETURN_UNDEF, // just return unknown
|
||||
IUB_USE_TACTIC_IF_QF, // invoke tactic if problem is quantifier free
|
||||
IUB_USE_TACTIC // invoke tactic
|
||||
};
|
||||
|
||||
private:
|
||||
ast_manager * m_manager;
|
||||
front_end_params * m_fparams;
|
||||
symbol m_logic;
|
||||
bool m_force_tactic; // use tactics even when auto_config = false
|
||||
bool m_inc_mode;
|
||||
bool m_check_sat_executed;
|
||||
scoped_ptr<solver> m_inc_solver;
|
||||
unsigned m_inc_solver_timeout;
|
||||
inc_unknown_behavior m_inc_unknown_behavior;
|
||||
scoped_ptr<tactic_factory> m_default_fct;
|
||||
dictionary<tactic_factory*> m_logic2fct;
|
||||
|
||||
ref<tactic> m_curr_tactic;
|
||||
|
||||
bool m_use_inc_solver_results;
|
||||
model_ref m_model;
|
||||
proof * m_proof;
|
||||
std::string m_reason_unknown;
|
||||
statistics m_stats;
|
||||
|
||||
#ifdef Z3DEBUG
|
||||
unsigned m_num_scopes;
|
||||
#endif
|
||||
|
||||
bool m_produce_proofs;
|
||||
bool m_produce_models;
|
||||
bool m_produce_unsat_cores;
|
||||
|
||||
progress_callback * m_callback;
|
||||
|
||||
void reset_results();
|
||||
void init_inc_solver();
|
||||
tactic_factory * get_tactic_factory() const;
|
||||
lbool check_sat_with_assumptions(unsigned num_assumptions, expr * const * assumptions);
|
||||
|
||||
struct mk_tactic;
|
||||
|
||||
bool has_quantifiers() const;
|
||||
bool use_tactic_when_undef() const;
|
||||
|
||||
public:
|
||||
strategic_solver();
|
||||
~strategic_solver();
|
||||
|
||||
ast_manager & m() const { SASSERT(m_manager); return *m_manager; }
|
||||
|
||||
void set_inc_solver(solver * s);
|
||||
void set_inc_solver_timeout(unsigned timeout);
|
||||
void set_default_tactic(tactic_factory * fct);
|
||||
void set_tactic_for(symbol const & logic, tactic_factory * fct);
|
||||
void set_inc_unknown_behavior(inc_unknown_behavior b) { m_inc_unknown_behavior = b; }
|
||||
void force_tactic(bool f) { m_force_tactic = f; }
|
||||
|
||||
virtual void set_front_end_params(front_end_params & p) { m_fparams = &p; }
|
||||
|
||||
virtual void updt_params(params_ref const & p);
|
||||
virtual void collect_param_descrs(param_descrs & r);
|
||||
|
||||
virtual void set_produce_proofs(bool f) { m_produce_proofs = f; }
|
||||
virtual void set_produce_models(bool f) { m_produce_models = f; }
|
||||
virtual void set_produce_unsat_cores(bool f) { m_produce_unsat_cores = f; }
|
||||
|
||||
virtual unsigned get_num_assertions() const = 0;
|
||||
virtual expr * get_assertion(unsigned idx) const = 0;
|
||||
|
||||
virtual void display(std::ostream & out) const;
|
||||
|
||||
virtual void init(ast_manager & m, symbol const & logic);
|
||||
virtual void collect_statistics(statistics & st) const;
|
||||
virtual void reset();
|
||||
virtual void assert_expr(expr * t);
|
||||
virtual void push();
|
||||
virtual void pop(unsigned n);
|
||||
virtual unsigned get_scope_level() const;
|
||||
virtual lbool check_sat(unsigned num_assumptions, expr * const * assumptions);
|
||||
virtual void get_unsat_core(ptr_vector<expr> & r);
|
||||
virtual void get_model(model_ref & m);
|
||||
virtual proof * get_proof();
|
||||
virtual std::string reason_unknown() const;
|
||||
virtual void get_labels(svector<symbol> & r);
|
||||
virtual void set_cancel(bool f);
|
||||
virtual void set_progress_callback(progress_callback * callback);
|
||||
};
|
||||
|
||||
// Specialization for the SMT 2.0 command language frontend
|
||||
class strategic_solver_cmd : public strategic_solver {
|
||||
cmd_context & m_ctx;
|
||||
public:
|
||||
strategic_solver_cmd(cmd_context & ctx);
|
||||
virtual unsigned get_num_assertions() const;
|
||||
virtual expr * get_assertion(unsigned idx) const;
|
||||
};
|
||||
|
||||
// Specialization for Z3 API
|
||||
class strategic_solver_api : public strategic_solver {
|
||||
struct ctx {
|
||||
expr_ref_vector m_assertions;
|
||||
unsigned_vector m_scopes;
|
||||
ctx(ast_manager & m);
|
||||
};
|
||||
scoped_ptr<ctx> m_ctx;
|
||||
public:
|
||||
strategic_solver_api() {}
|
||||
|
||||
virtual void init(ast_manager & m, symbol const & logic);
|
||||
|
||||
virtual void assert_expr(expr * t);
|
||||
virtual void push();
|
||||
virtual void pop(unsigned n);
|
||||
virtual void reset();
|
||||
|
||||
virtual unsigned get_num_assertions() const;
|
||||
virtual expr * get_assertion(unsigned idx) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
34
src/cmd_context/strategic_solver_cmd.cpp
Normal file
34
src/cmd_context/strategic_solver_cmd.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
strategic_solver_cmd.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Specialization of the strategic solver that
|
||||
used cmd_context to access the assertion set.
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2012-11-01
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#include"strategic_solver_cmd.h"
|
||||
#include"cmd_context.h"
|
||||
|
||||
strategic_solver_cmd::strategic_solver_cmd(cmd_context & ctx):
|
||||
m_ctx(ctx) {
|
||||
}
|
||||
|
||||
unsigned strategic_solver_cmd::get_num_assertions() const {
|
||||
return static_cast<unsigned>(m_ctx.end_assertions() - m_ctx.begin_assertions());
|
||||
}
|
||||
|
||||
expr * strategic_solver_cmd::get_assertion(unsigned idx) const {
|
||||
SASSERT(idx < get_num_assertions());
|
||||
return m_ctx.begin_assertions()[idx];
|
||||
}
|
40
src/cmd_context/strategic_solver_cmd.h
Normal file
40
src/cmd_context/strategic_solver_cmd.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
strategic_solver_cmd.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Specialization of the strategic solver that
|
||||
used cmd_context to access the assertion set.
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2012-11-01
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _STRATEGIC_SOLVER_CMD_H_
|
||||
#define _STRATEGIC_SOLVER_CMD_H_
|
||||
|
||||
#include"strategic_solver.h"
|
||||
|
||||
class cmd_context;
|
||||
|
||||
/**
|
||||
Specialization for the SMT 2.0 command language frontend.
|
||||
|
||||
The strategic solver does not have to maintain a copy of the assertion set in the cmd_context.
|
||||
*/
|
||||
class strategic_solver_cmd : public strategic_solver_core {
|
||||
cmd_context & m_ctx;
|
||||
public:
|
||||
strategic_solver_cmd(cmd_context & ctx);
|
||||
virtual unsigned get_num_assertions() const;
|
||||
virtual expr * get_assertion(unsigned idx) const;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,249 +0,0 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
tactic2solver.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
Wrapper for implementing the solver interface
|
||||
using a tactic.
|
||||
|
||||
This is a light version of the strategic solver.
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2012-01-23
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#include"tactic2solver.h"
|
||||
#include"params2front_end_params.h"
|
||||
#include"ast_smt2_pp.h"
|
||||
|
||||
tactic2solver::ctx::ctx(ast_manager & m, symbol const & logic):
|
||||
m_logic(logic),
|
||||
m_assertions(m) {
|
||||
}
|
||||
|
||||
tactic2solver::~tactic2solver() {
|
||||
}
|
||||
|
||||
void tactic2solver::init(ast_manager & m, symbol const & logic) {
|
||||
m_ctx = alloc(ctx, m, logic);
|
||||
}
|
||||
|
||||
void tactic2solver::updt_params(params_ref const & p) {
|
||||
m_params = p;
|
||||
}
|
||||
|
||||
void tactic2solver::collect_param_descrs(param_descrs & r) {
|
||||
if (m_ctx) {
|
||||
if (!m_ctx->m_tactic) {
|
||||
#pragma omp critical (tactic2solver)
|
||||
{
|
||||
m_ctx->m_tactic = get_tactic(m_ctx->m(), m_params);
|
||||
}
|
||||
|
||||
if (m_ctx->m_tactic) {
|
||||
m_ctx->m_tactic->collect_param_descrs(r);
|
||||
}
|
||||
|
||||
#pragma omp critical (tactic2solver)
|
||||
{
|
||||
m_ctx->m_tactic = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
m_ctx->m_tactic->collect_param_descrs(r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tactic2solver::reset() {
|
||||
SASSERT(m_ctx);
|
||||
m_ctx->m_assertions.reset();
|
||||
m_ctx->m_scopes.reset();
|
||||
m_ctx->m_result = 0;
|
||||
}
|
||||
|
||||
void tactic2solver::assert_expr(expr * t) {
|
||||
SASSERT(m_ctx);
|
||||
m_ctx->m_assertions.push_back(t);
|
||||
m_ctx->m_result = 0;
|
||||
}
|
||||
|
||||
void tactic2solver::push() {
|
||||
SASSERT(m_ctx);
|
||||
m_ctx->m_scopes.push_back(m_ctx->m_assertions.size());
|
||||
m_ctx->m_result = 0;
|
||||
}
|
||||
|
||||
void tactic2solver::pop(unsigned n) {
|
||||
SASSERT(m_ctx);
|
||||
unsigned new_lvl = m_ctx->m_scopes.size() - n;
|
||||
unsigned old_sz = m_ctx->m_scopes[new_lvl];
|
||||
m_ctx->m_assertions.shrink(old_sz);
|
||||
m_ctx->m_scopes.shrink(new_lvl);
|
||||
m_ctx->m_result = 0;
|
||||
}
|
||||
|
||||
unsigned tactic2solver::get_scope_level() const {
|
||||
SASSERT(m_ctx);
|
||||
return m_ctx->m_scopes.size();
|
||||
}
|
||||
|
||||
lbool tactic2solver::check_sat(unsigned num_assumptions, expr * const * assumptions) {
|
||||
SASSERT(m_ctx);
|
||||
ast_manager & m = m_ctx->m();
|
||||
params_ref p = m_params;
|
||||
if (m_fparams)
|
||||
front_end_params2params(*m_fparams, p);
|
||||
#pragma omp critical (tactic2solver)
|
||||
{
|
||||
m_ctx->m_tactic = get_tactic(m, p);
|
||||
if (m_ctx->m_tactic) {
|
||||
m_ctx->m_result = alloc(simple_check_sat_result, m);
|
||||
}
|
||||
}
|
||||
if (!m_ctx->m_tactic)
|
||||
return l_undef;
|
||||
tactic & t = *(m_ctx->m_tactic);
|
||||
simple_check_sat_result & result = *(m_ctx->m_result);
|
||||
if (m_fparams)
|
||||
t.set_front_end_params(*m_fparams);
|
||||
goal_ref g = alloc(goal, m, m_produce_proofs, m_produce_models, m_produce_unsat_cores);
|
||||
t.set_logic(m_ctx->m_logic);
|
||||
unsigned sz = m_ctx->m_assertions.size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
g->assert_expr(m_ctx->m_assertions.get(i));
|
||||
}
|
||||
for (unsigned i = 0; i < num_assumptions; i++) {
|
||||
g->assert_expr(assumptions[i], m.mk_asserted(assumptions[i]), m.mk_leaf(assumptions[i]));
|
||||
}
|
||||
|
||||
model_ref md;
|
||||
proof_ref pr(m);
|
||||
expr_dependency_ref core(m);
|
||||
std::string reason_unknown = "unknown";
|
||||
try {
|
||||
switch (::check_sat(t, g, md, pr, core, reason_unknown)) {
|
||||
case l_true:
|
||||
result.set_status(l_true);
|
||||
break;
|
||||
case l_false:
|
||||
result.set_status(l_false);
|
||||
break;
|
||||
default:
|
||||
result.set_status(l_undef);
|
||||
if (reason_unknown != "")
|
||||
result.m_unknown = reason_unknown;
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (z3_error & ex) {
|
||||
throw ex;
|
||||
}
|
||||
catch (z3_exception & ex) {
|
||||
TRACE("tactic2solver", tout << "exception: " << ex.msg() << "\n";);
|
||||
result.set_status(l_undef);
|
||||
result.m_unknown = ex.msg();
|
||||
}
|
||||
t.collect_statistics(result.m_stats);
|
||||
result.m_model = md;
|
||||
result.m_proof = pr;
|
||||
if (m_produce_unsat_cores) {
|
||||
ptr_vector<expr> core_elems;
|
||||
m.linearize(core, core_elems);
|
||||
result.m_core.append(core_elems.size(), core_elems.c_ptr());
|
||||
}
|
||||
|
||||
#pragma omp critical (tactic2solver)
|
||||
{
|
||||
m_ctx->m_tactic = 0;
|
||||
}
|
||||
return result.status();
|
||||
}
|
||||
|
||||
void tactic2solver::set_cancel(bool f) {
|
||||
#pragma omp critical (tactic2solver)
|
||||
{
|
||||
if (m_ctx && m_ctx->m_tactic)
|
||||
m_ctx->m_tactic->set_cancel(f);
|
||||
}
|
||||
}
|
||||
|
||||
void tactic2solver::collect_statistics(statistics & st) const {
|
||||
if (m_ctx->m_result.get())
|
||||
m_ctx->m_result->collect_statistics(st);
|
||||
}
|
||||
|
||||
void tactic2solver::get_unsat_core(ptr_vector<expr> & r) {
|
||||
if (m_ctx->m_result.get())
|
||||
m_ctx->m_result->get_unsat_core(r);
|
||||
}
|
||||
|
||||
void tactic2solver::get_model(model_ref & m) {
|
||||
if (m_ctx->m_result.get())
|
||||
m_ctx->m_result->get_model(m);
|
||||
}
|
||||
|
||||
proof * tactic2solver::get_proof() {
|
||||
if (m_ctx->m_result.get())
|
||||
return m_ctx->m_result->get_proof();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string tactic2solver::reason_unknown() const {
|
||||
if (m_ctx->m_result.get())
|
||||
return m_ctx->m_result->reason_unknown();
|
||||
else
|
||||
return std::string("unknown");
|
||||
}
|
||||
|
||||
unsigned tactic2solver::get_num_assertions() const {
|
||||
if (m_ctx)
|
||||
return m_ctx->m_assertions.size();
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
expr * tactic2solver::get_assertion(unsigned idx) const {
|
||||
SASSERT(m_ctx);
|
||||
return m_ctx->m_assertions.get(idx);
|
||||
}
|
||||
|
||||
void tactic2solver::display(std::ostream & out) const {
|
||||
if (m_ctx) {
|
||||
ast_manager & m = m_ctx->m_assertions.m();
|
||||
unsigned num = m_ctx->m_assertions.size();
|
||||
out << "(solver";
|
||||
for (unsigned i = 0; i < num; i++) {
|
||||
out << "\n " << mk_ismt2_pp(m_ctx->m_assertions.get(i), m, 2);
|
||||
}
|
||||
out << ")";
|
||||
}
|
||||
else {
|
||||
out << "(solver)";
|
||||
}
|
||||
}
|
||||
|
||||
void tactic2solver_cmd::set_tactic(tactic_factory * f) {
|
||||
m_tactic_factory = f;
|
||||
}
|
||||
|
||||
tactic * tactic2solver_cmd::get_tactic(ast_manager & m, params_ref const & p) {
|
||||
if (m_tactic_factory == 0)
|
||||
return 0;
|
||||
return (*m_tactic_factory)(m, p);
|
||||
}
|
||||
|
||||
tactic * tactic2solver_api::get_tactic(ast_manager & m, params_ref const & p) {
|
||||
m_tactic->cleanup();
|
||||
m_tactic->updt_params(p);
|
||||
return m_tactic.get();
|
||||
}
|
||||
|
|
@ -1,110 +0,0 @@
|
|||
/*++
|
||||
Copyright (c) 2012 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
tactic2solver.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Wrapper for implementing the external solver interface
|
||||
using a tactic.
|
||||
|
||||
This is a light version of the strategic solver.
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2012-01-23
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _TACTIC2SOLVER_H_
|
||||
#define _TACTIC2SOLVER_H_
|
||||
|
||||
#include"solver.h"
|
||||
#include"tactic.h"
|
||||
|
||||
class tactic2solver : public solver {
|
||||
struct ctx {
|
||||
symbol m_logic;
|
||||
expr_ref_vector m_assertions;
|
||||
unsigned_vector m_scopes;
|
||||
ref<simple_check_sat_result> m_result;
|
||||
tactic_ref m_tactic;
|
||||
ctx(ast_manager & m, symbol const & logic);
|
||||
ast_manager & m() const { return m_assertions.m(); }
|
||||
};
|
||||
scoped_ptr<ctx> m_ctx;
|
||||
front_end_params * m_fparams;
|
||||
params_ref m_params;
|
||||
bool m_produce_models;
|
||||
bool m_produce_proofs;
|
||||
bool m_produce_unsat_cores;
|
||||
public:
|
||||
tactic2solver():m_ctx(0), m_fparams(0), m_produce_models(false), m_produce_proofs(false), m_produce_unsat_cores(false) {}
|
||||
virtual ~tactic2solver();
|
||||
|
||||
virtual tactic * get_tactic(ast_manager & m, params_ref const & p) = 0;
|
||||
|
||||
virtual void set_front_end_params(front_end_params & p) { m_fparams = &p; }
|
||||
|
||||
virtual void updt_params(params_ref const & p);
|
||||
virtual void collect_param_descrs(param_descrs & r);
|
||||
|
||||
virtual void set_produce_proofs(bool f) { m_produce_proofs = f; }
|
||||
virtual void set_produce_models(bool f) { m_produce_models = f; }
|
||||
virtual void set_produce_unsat_cores(bool f) { m_produce_unsat_cores = f; }
|
||||
|
||||
virtual void init(ast_manager & m, symbol const & logic);
|
||||
virtual void reset();
|
||||
virtual void assert_expr(expr * t);
|
||||
virtual void push();
|
||||
virtual void pop(unsigned n);
|
||||
virtual unsigned get_scope_level() const;
|
||||
virtual lbool check_sat(unsigned num_assumptions, expr * const * assumptions);
|
||||
|
||||
virtual void set_cancel(bool f);
|
||||
|
||||
virtual void collect_statistics(statistics & st) const;
|
||||
virtual void get_unsat_core(ptr_vector<expr> & r);
|
||||
virtual void get_model(model_ref & m);
|
||||
virtual proof * get_proof();
|
||||
virtual std::string reason_unknown() const;
|
||||
virtual void get_labels(svector<symbol> & r) {}
|
||||
|
||||
virtual void set_progress_callback(progress_callback * callback) {}
|
||||
|
||||
virtual unsigned get_num_assertions() const;
|
||||
virtual expr * get_assertion(unsigned idx) const;
|
||||
|
||||
virtual void display(std::ostream & out) const;
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Specialization for cmd_context
|
||||
*/
|
||||
class tactic2solver_cmd : public tactic2solver {
|
||||
scoped_ptr<tactic_factory> m_tactic_factory;
|
||||
public:
|
||||
virtual ~tactic2solver_cmd() {}
|
||||
/**
|
||||
\brief Set tactic that will be used to process the satisfiability queries.
|
||||
*/
|
||||
void set_tactic(tactic_factory * f);
|
||||
virtual tactic * get_tactic(ast_manager & m, params_ref const & p);
|
||||
};
|
||||
|
||||
/**
|
||||
\brief Specialization for API
|
||||
*/
|
||||
class tactic2solver_api : public tactic2solver {
|
||||
tactic_ref m_tactic;
|
||||
public:
|
||||
tactic2solver_api(tactic * t):m_tactic(t) {}
|
||||
virtual ~tactic2solver_api() {}
|
||||
virtual tactic * get_tactic(ast_manager & m, params_ref const & p);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue