mirror of
https://github.com/Z3Prover/z3
synced 2025-08-26 13:06:05 +00:00
porting bv-sls
This commit is contained in:
parent
e7104ebb93
commit
ef54feec3d
18 changed files with 264 additions and 811 deletions
|
@ -124,116 +124,11 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class bv_sls_tactic : public tactic {
|
||||
ast_manager& m;
|
||||
params_ref m_params;
|
||||
bv::sls* m_sls;
|
||||
statistics m_st;
|
||||
|
||||
public:
|
||||
bv_sls_tactic(ast_manager& _m, params_ref const& p) :
|
||||
m(_m),
|
||||
m_params(p) {
|
||||
m_sls = alloc(bv::sls, m, p);
|
||||
}
|
||||
|
||||
tactic* translate(ast_manager& m) override {
|
||||
return alloc(bv_sls_tactic, m, m_params);
|
||||
}
|
||||
|
||||
~bv_sls_tactic() override {
|
||||
dealloc(m_sls);
|
||||
}
|
||||
|
||||
char const* name() const override { return "bv-sls"; }
|
||||
|
||||
void updt_params(params_ref const& p) override {
|
||||
m_params.append(p);
|
||||
m_sls->updt_params(m_params);
|
||||
}
|
||||
|
||||
void collect_param_descrs(param_descrs& r) override {
|
||||
sls_params::collect_param_descrs(r);
|
||||
}
|
||||
|
||||
void run(goal_ref const& g, model_converter_ref& mc) {
|
||||
if (g->inconsistent()) {
|
||||
mc = nullptr;
|
||||
return;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < g->size(); i++)
|
||||
m_sls->assert_expr(g->form(i));
|
||||
|
||||
m_sls->init();
|
||||
std::function<bool(expr*, unsigned)> false_eval = [&](expr* e, unsigned idx) {
|
||||
return false;
|
||||
};
|
||||
m_sls->init_eval(false_eval);
|
||||
|
||||
lbool res = m_sls->operator()();
|
||||
m_st.reset();
|
||||
m_sls->collect_statistics(m_st);
|
||||
report_tactic_progress("Number of flips:", m_sls->get_num_moves());
|
||||
IF_VERBOSE(10, verbose_stream() << res << "\n");
|
||||
IF_VERBOSE(10, m_sls->display(verbose_stream()));
|
||||
|
||||
if (res == l_true) {
|
||||
if (g->models_enabled()) {
|
||||
model_ref mdl = m_sls->get_model();
|
||||
mc = model2model_converter(mdl.get());
|
||||
TRACE("sls_model", mc->display(tout););
|
||||
}
|
||||
g->reset();
|
||||
}
|
||||
else
|
||||
mc = nullptr;
|
||||
|
||||
}
|
||||
|
||||
void operator()(goal_ref const& g,
|
||||
goal_ref_buffer& result) override {
|
||||
result.reset();
|
||||
|
||||
TRACE("sls", g->display(tout););
|
||||
tactic_report report("sls", *g);
|
||||
|
||||
model_converter_ref mc;
|
||||
run(g, mc);
|
||||
g->add(mc.get());
|
||||
g->inc_depth();
|
||||
result.push_back(g.get());
|
||||
}
|
||||
|
||||
void cleanup() override {
|
||||
|
||||
auto* d = alloc(bv::sls, m, m_params);
|
||||
std::swap(d, m_sls);
|
||||
dealloc(d);
|
||||
}
|
||||
|
||||
void collect_statistics(statistics& st) const override {
|
||||
st.copy(m_st);
|
||||
}
|
||||
|
||||
void reset_statistics() override {
|
||||
m_sls->reset_statistics();
|
||||
m_st.reset();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static tactic * mk_sls_tactic(ast_manager & m, params_ref const & p) {
|
||||
return and_then(fail_if_not(mk_is_qfbv_probe()), // Currently only QF_BV is supported.
|
||||
clean(alloc(sls_tactic, m, p)));
|
||||
}
|
||||
|
||||
tactic* mk_bv_sls_tactic(ast_manager& m, params_ref const& p) {
|
||||
return and_then(fail_if_not(mk_is_qfbv_probe()), // Currently only QF_BV is supported.
|
||||
clean(alloc(bv_sls_tactic, m, p)));
|
||||
}
|
||||
|
||||
|
||||
static tactic * mk_preamble(ast_manager & m, params_ref const & p) {
|
||||
|
||||
params_ref simp2_p = p;
|
||||
|
@ -268,10 +163,3 @@ tactic * mk_qfbv_sls_tactic(ast_manager & m, params_ref const & p) {
|
|||
return t;
|
||||
}
|
||||
|
||||
tactic* mk_qfbv_new_sls_tactic(ast_manager& m, params_ref const& p) {
|
||||
params_ref q = p;
|
||||
q.set_bool("elim_sign_ext", false);
|
||||
tactic* t = and_then(mk_preamble(m, q), mk_bv_sls_tactic(m, q));
|
||||
t->updt_params(q);
|
||||
return t;
|
||||
}
|
||||
|
|
|
@ -24,16 +24,8 @@ class tactic;
|
|||
|
||||
tactic * mk_qfbv_sls_tactic(ast_manager & m, params_ref const & p = params_ref());
|
||||
|
||||
tactic* mk_qfbv_new_sls_tactic(ast_manager& m, params_ref const& p = params_ref());
|
||||
|
||||
tactic* mk_bv_sls_tactic(ast_manager& m, params_ref const& p = params_ref());
|
||||
|
||||
/*
|
||||
ADD_TACTIC("qfbv-sls", "(try to) solve using stochastic local search for QF_BV.", "mk_qfbv_sls_tactic(m, p)")
|
||||
|
||||
ADD_TACTIC("qfbv-new-sls", "(try to) solve using stochastic local search for QF_BV.", "mk_qfbv_new_sls_tactic(m, p)")
|
||||
|
||||
ADD_TACTIC("qfbv-new-sls-core", "(try to) solve using stochastic local search for QF_BV.", "mk_bv_sls_tactic(m, p)")
|
||||
|
||||
*/
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue