mirror of
https://github.com/Z3Prover/z3
synced 2025-08-23 03:27:52 +00:00
abstract solver API
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
9cf99e26a6
commit
d04e72819a
11 changed files with 237 additions and 110 deletions
|
@ -29,12 +29,12 @@ class sat_tactic : public tactic {
|
|||
ast_manager & m;
|
||||
goal2sat m_goal2sat;
|
||||
sat2goal m_sat2goal;
|
||||
sat::solver m_solver;
|
||||
scoped_ptr<sat::solver_core> m_solver;
|
||||
params_ref m_params;
|
||||
|
||||
imp(ast_manager & _m, params_ref const & p):
|
||||
m(_m),
|
||||
m_solver(p, m.limit()),
|
||||
m_solver(alloc(sat::solver, p, m.limit())),
|
||||
m_params(p) {
|
||||
SASSERT(!m.proofs_enabled());
|
||||
updt_params(p);
|
||||
|
@ -51,7 +51,7 @@ class sat_tactic : public tactic {
|
|||
atom2bool_var map(m);
|
||||
obj_map<expr, sat::literal> dep2asm;
|
||||
sat::literal_vector assumptions;
|
||||
m_goal2sat(*g, m_params, m_solver, map, dep2asm);
|
||||
m_goal2sat(*g, m_params, *m_solver, map, dep2asm);
|
||||
TRACE("sat_solver_unknown", tout << "interpreted_atoms: " << map.interpreted_atoms() << "\n";
|
||||
for (auto const& kv : map) {
|
||||
if (!is_uninterp_const(kv.m_key))
|
||||
|
@ -60,15 +60,15 @@ class sat_tactic : public tactic {
|
|||
g->reset();
|
||||
g->m().compact_memory();
|
||||
|
||||
CASSERT("sat_solver", m_solver.check_invariant());
|
||||
IF_VERBOSE(TACTIC_VERBOSITY_LVL, m_solver.display_status(verbose_stream()););
|
||||
TRACE("sat_dimacs", m_solver.display_dimacs(tout););
|
||||
CASSERT("sat_solver", m_solver->check_invariant());
|
||||
IF_VERBOSE(TACTIC_VERBOSITY_LVL, m_solver->display_status(verbose_stream()););
|
||||
TRACE("sat_dimacs", m_solver->display_dimacs(tout););
|
||||
dep2assumptions(dep2asm, assumptions);
|
||||
lbool r = m_solver.check(assumptions.size(), assumptions.c_ptr());
|
||||
lbool r = m_solver->check(assumptions.size(), assumptions.c_ptr());
|
||||
if (r == l_false) {
|
||||
expr_dependency * lcore = nullptr;
|
||||
if (produce_core) {
|
||||
sat::literal_vector const& ucore = m_solver.get_core();
|
||||
sat::literal_vector const& ucore = m_solver->get_core();
|
||||
u_map<expr*> asm2dep;
|
||||
mk_asm2dep(dep2asm, asm2dep);
|
||||
for (unsigned i = 0; i < ucore.size(); ++i) {
|
||||
|
@ -83,7 +83,7 @@ class sat_tactic : public tactic {
|
|||
// register model
|
||||
if (produce_models) {
|
||||
model_ref md = alloc(model, m);
|
||||
sat::model const & ll_m = m_solver.get_model();
|
||||
sat::model const & ll_m = m_solver->get_model();
|
||||
TRACE("sat_tactic", for (unsigned i = 0; i < ll_m.size(); i++) tout << i << ":" << ll_m[i] << " "; tout << "\n";);
|
||||
for (auto const& kv : map) {
|
||||
expr * n = kv.m_key;
|
||||
|
@ -109,9 +109,9 @@ class sat_tactic : public tactic {
|
|||
#if 0
|
||||
IF_VERBOSE(TACTIC_VERBOSITY_LVL, verbose_stream() << "\"formula constrains interpreted atoms, recovering formula from sat solver...\"\n";);
|
||||
#endif
|
||||
m_solver.pop_to_base_level();
|
||||
m_solver->pop_to_base_level();
|
||||
ref<sat2goal::mc> mc;
|
||||
m_sat2goal(m_solver, map, m_params, *(g.get()), mc);
|
||||
m_sat2goal(*m_solver, map, m_params, *(g.get()), mc);
|
||||
g->add(mc.get());
|
||||
}
|
||||
g->inc_depth();
|
||||
|
@ -134,7 +134,7 @@ class sat_tactic : public tactic {
|
|||
}
|
||||
|
||||
void updt_params(params_ref const& p) {
|
||||
m_solver.updt_params(p);
|
||||
m_solver->updt_params(p);
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -192,10 +192,10 @@ public:
|
|||
scoped_set_imp set(this, &proc);
|
||||
try {
|
||||
proc(g, result);
|
||||
proc.m_solver.collect_statistics(m_stats);
|
||||
proc.m_solver->collect_statistics(m_stats);
|
||||
}
|
||||
catch (sat::solver_exception & ex) {
|
||||
proc.m_solver.collect_statistics(m_stats);
|
||||
proc.m_solver->collect_statistics(m_stats);
|
||||
throw tactic_exception(ex.msg());
|
||||
}
|
||||
TRACE("sat_stats", m_stats.display_smt2(tout););
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue