mirror of
https://github.com/Z3Prover/z3
synced 2025-04-24 09:35:32 +00:00
initial stab at new bv-sls based on repair actions
This commit is contained in:
parent
10687082f1
commit
f39756c74b
17 changed files with 2278 additions and 45 deletions
|
@ -29,6 +29,7 @@ Notes:
|
|||
#include "tactic/sls/sls_tactic.h"
|
||||
#include "params/sls_params.hpp"
|
||||
#include "ast/sls/sls_engine.h"
|
||||
#include "ast/sls/bv_sls.h"
|
||||
|
||||
class sls_tactic : public tactic {
|
||||
ast_manager & m;
|
||||
|
@ -123,11 +124,111 @@ public:
|
|||
|
||||
};
|
||||
|
||||
class bv_sls_tactic : public tactic {
|
||||
ast_manager& m;
|
||||
params_ref m_params;
|
||||
bv::sls* m_engine;
|
||||
|
||||
public:
|
||||
bv_sls_tactic(ast_manager& _m, params_ref const& p) :
|
||||
m(_m),
|
||||
m_params(p) {
|
||||
m_engine = alloc(bv::sls, m);
|
||||
}
|
||||
|
||||
tactic* translate(ast_manager& m) override {
|
||||
return alloc(bv_sls_tactic, m, m_params);
|
||||
}
|
||||
|
||||
~bv_sls_tactic() override {
|
||||
dealloc(m_engine);
|
||||
}
|
||||
|
||||
char const* name() const override { return "bv-sls"; }
|
||||
|
||||
void updt_params(params_ref const& p) override {
|
||||
m_params.append(p);
|
||||
m_engine->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_engine->assert_expr(g->form(i));
|
||||
|
||||
m_engine->init();
|
||||
std::function<bool(expr*, unsigned)> false_eval = [&](expr* e, unsigned idx) {
|
||||
return false;
|
||||
};
|
||||
m_engine->init_eval(false_eval);
|
||||
|
||||
lbool res = m_engine->operator()();
|
||||
auto const& stats = m_engine->get_stats();
|
||||
report_tactic_progress("Number of flips:", stats.m_moves);
|
||||
IF_VERBOSE(0, verbose_stream() << res << "\n");
|
||||
IF_VERBOSE(0, m_engine->display(verbose_stream()));
|
||||
if (res == l_true) {
|
||||
|
||||
if (g->models_enabled()) {
|
||||
model_ref mdl = m_engine->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);
|
||||
std::swap(d, m_engine);
|
||||
dealloc(d);
|
||||
}
|
||||
|
||||
void collect_statistics(statistics& st) const override {
|
||||
m_engine->collect_statistics(st);
|
||||
}
|
||||
|
||||
void reset_statistics() override {
|
||||
m_engine->reset_statistics();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
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 main_p;
|
||||
|
@ -171,3 +272,9 @@ tactic * mk_qfbv_sls_tactic(ast_manager & m, params_ref const & p) {
|
|||
t->updt_params(p);
|
||||
return t;
|
||||
}
|
||||
|
||||
tactic* mk_qfbv_new_sls_tactic(ast_manager& m, params_ref const& p) {
|
||||
tactic* t = and_then(mk_preamble(m, p), mk_bv_sls_tactic(m, p));
|
||||
t->updt_params(p);
|
||||
return t;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,16 @@ 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