3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00

cleanup cancelation logic

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2015-12-11 12:35:35 -08:00
parent 4e155887b2
commit 61dbb6168e
37 changed files with 93 additions and 198 deletions

View file

@ -230,8 +230,7 @@ namespace datalog {
m_enable_bind_variables(true),
m_last_status(OK),
m_last_answer(m),
m_engine_type(LAST_ENGINE),
m_cancel(false) {
m_engine_type(LAST_ENGINE) {
re.set_context(this);
updt_params(pa);
}
@ -751,15 +750,16 @@ namespace datalog {
}
#if 0
void context::cancel() {
m_cancel = true;
m_last_status = CANCELED;
m_transf.cancel();
if (m_engine) m_engine->cancel();
}
#endif
void context::cleanup() {
m_cancel = false;
m_last_status = OK;
if (m_engine) m_engine->cleanup();
}

View file

@ -487,11 +487,13 @@ namespace datalog {
//
// -----------------------------------
void cancel();
bool canceled() const { return m_cancel; }
bool canceled() {
if (m.limit().inc()) return true;
m_last_status = CANCELED;
return false;
}
void cleanup();
void reset_cancel() { cleanup(); }
/**
\brief check if query 'q' is satisfied under asserted rules and background.

View file

@ -74,7 +74,6 @@ class hnf::imp {
ast_manager& m;
bool m_produce_proofs;
volatile bool m_cancel;
expr_ref_vector m_todo;
proof_ref_vector m_proofs;
expr_ref_vector m_refs;
@ -96,7 +95,6 @@ public:
imp(ast_manager & m):
m(m),
m_produce_proofs(false),
m_cancel(false),
m_todo(m),
m_proofs(m),
m_refs(m),
@ -156,7 +154,7 @@ public:
m_todo.push_back(n);
m_proofs.push_back(p);
m_produce_proofs = p != 0;
while (!m_todo.empty() && !m_cancel) {
while (!m_todo.empty() && checkpoint()) {
fml = m_todo.back();
pr = m_proofs.back();
m_todo.pop_back();
@ -174,8 +172,8 @@ public:
});
}
void set_cancel(bool f) {
m_cancel = f;
bool checkpoint() {
return m.limit().inc();
}
void set_name(symbol const& n) {
@ -192,7 +190,6 @@ public:
}
void reset() {
m_cancel = false;
m_todo.reset();
m_proofs.reset();
m_refs.reset();
@ -524,9 +521,6 @@ void hnf::operator()(expr * n, proof* p, expr_ref_vector & rs, proof_ref_vector&
);
}
void hnf::set_cancel(bool f) {
m_imp->set_cancel(f);
}
void hnf::set_name(symbol const& n) {
m_imp->set_name(n);

View file

@ -43,9 +43,6 @@ class hnf {
proof_ref_vector& ps // [OUT] proofs of rs
);
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
void set_cancel(bool f);
void set_name(symbol const& name);
void reset();
func_decl_ref_vector const& get_fresh_predicates();

View file

@ -470,7 +470,6 @@ namespace datalog {
ast_manager& m;
rule_manager& rm;
bv_util bv;
volatile bool m_cancel;
ptr_vector<expr> m_todo;
ast_mark m_visited1, m_visited2;
ddnfs m_ddnfs;
@ -486,7 +485,6 @@ namespace datalog {
m(ctx.get_manager()),
rm(ctx.get_rule_manager()),
bv(m),
m_cancel(false),
m_trail(m),
m_inner_ctx(m, m_ctx.get_register_engine(), m_ctx.get_fparams())
{
@ -518,15 +516,7 @@ namespace datalog {
// return execute_rules(new_rules);
}
void cancel() {
m_cancel = true;
m_inner_ctx.cancel();
}
void cleanup() {
m_cancel = false;
}
void reset_statistics() {
m_stats.reset();
}
@ -884,12 +874,6 @@ namespace datalog {
lbool ddnf::query(expr* query) {
return m_imp->query(query);
}
void ddnf::cancel() {
m_imp->cancel();
}
void ddnf::cleanup() {
m_imp->cleanup();
}
void ddnf::reset_statistics() {
m_imp->reset_statistics();
}

View file

@ -37,8 +37,6 @@ namespace datalog {
ddnf(context& ctx);
~ddnf();
virtual lbool query(expr* query);
virtual void cancel();
virtual void cleanup();
virtual void reset_statistics();
virtual void collect_statistics(statistics& st) const;
virtual void display_certificate(std::ostream& out) const;

View file

@ -230,7 +230,7 @@ public:
set_background(ctx);
dlctx.updt_params(m_params);
unsigned timeout = m_dl_ctx->get_params().timeout();
cancel_eh<datalog::context> eh(dlctx);
cancel_eh<reslimit> eh(ctx.m().limit());
bool query_exn = false;
lbool status = l_undef;
{

View file

@ -64,9 +64,6 @@ class horn_tactic : public tactic {
}
void set_cancel(bool f) {
if (f) {
m_ctx.cancel();
}
}
void normalize(expr_ref& f) {

View file

@ -270,8 +270,6 @@ namespace datalog {
symbol const& get_name() const { return m_name; }
virtual void set_cancel(bool f) {}
relation_manager & get_manager() const { return m_manager; }
ast_manager& get_ast_manager() const { return datalog::get_ast_manager_from_rel_manager(m_manager); }
context& get_context() const { return datalog::get_context_from_rel_manager(m_manager); }

View file

@ -54,8 +54,6 @@ namespace datalog {
virtual table_base * mk_empty(const table_signature & s);
virtual void set_cancel(bool f) { m_plugin.set_cancel(f); }
static table_plugin* mk_sparse(relation_manager& rm);
protected:

View file

@ -463,12 +463,6 @@ namespace datalog {
}
}
void relation_manager::set_cancel(bool f) {
for (unsigned i = 0; i < m_relation_plugins.size(); ++i) {
m_relation_plugins[i]->set_cancel(f);
}
}
std::string relation_manager::to_nice_string(const relation_element & el) const {
uint64 val;
std::stringstream stm;

View file

@ -225,8 +225,6 @@ namespace datalog {
relation_fact & to);
void set_cancel(bool f);
// -----------------------------------
//

View file

@ -499,7 +499,6 @@ namespace datalog {
}
void karr_relation_plugin::set_cancel(bool f) {
m_hb.set_cancel(f);
}
relation_base * karr_relation_plugin::mk_empty(const relation_signature & s) {

View file

@ -41,6 +41,7 @@ namespace datalog {
public:
karr_relation_plugin(relation_manager& rm):
relation_plugin(karr_relation_plugin::get_name(), rm),
m_hb(get_ast_manager().limit()),
a(get_ast_manager())
{}

View file

@ -512,9 +512,6 @@ namespace datalog {
get_rmanager().set_predicate_kind(pred, target_kind);
}
void rel_context::set_cancel(bool f) {
get_rmanager().set_cancel(f);
}
void rel_context::setup_default_relation() {
if (m_context.default_relation() == symbol("doc")) {

View file

@ -51,8 +51,6 @@ namespace datalog {
lbool saturate(scoped_query& sq);
void set_cancel(bool f);
void setup_default_relation();
public:
@ -82,8 +80,6 @@ namespace datalog {
virtual void collect_statistics(statistics& st) const;
virtual void cancel() { set_cancel(true); }
virtual void cleanup() { set_cancel(false);}
virtual void updt_params();
/**

View file

@ -509,7 +509,6 @@ namespace tb {
bool_rewriter m_rw;
smt_params m_fparams;
smt::kernel m_solver;
volatile bool m_cancel;
public:
index(ast_manager& m):
@ -523,8 +522,7 @@ namespace tb {
m_subst(m),
m_qe(m),
m_rw(m),
m_solver(m, m_fparams),
m_cancel(false) {}
m_solver(m, m_fparams) {}
void insert(ref<clause>& g) {
m_index.push_back(g);
@ -540,17 +538,6 @@ namespace tb {
return found;
}
void cancel() {
m_cancel = true;
m_solver.cancel();
m_qe.set_cancel(true);
}
void cleanup() {
m_solver.reset_cancel();
m_qe.set_cancel(false);
m_cancel = false;
}
void reset() {
m_index.reset();
@ -594,7 +581,7 @@ namespace tb {
// extract pre_cond => post_cond validation obligation from match.
bool find_match(unsigned& subsumer) {
for (unsigned i = 0; !m_cancel && i < m_index.size(); ++i) {
for (unsigned i = 0; m.limit().inc() && i < m_index.size(); ++i) {
if (match_rule(i)) {
subsumer = m_index[i]->get_seqno();
return true;
@ -631,7 +618,7 @@ namespace tb {
app* q = g.get_predicate(predicate_index);
for (unsigned i = 0; !m_cancel && i < m_preds.size(); ++i) {
for (unsigned i = 0; m.limit().inc() && i < m_preds.size(); ++i) {
app* p = m_preds[i].get();
m_subst.push_scope();
unsigned limit = m_sideconds.size();
@ -660,7 +647,7 @@ namespace tb {
expr_ref_vector fmls(m_sideconds);
m_subst.reset_cache();
for (unsigned i = 0; !m_cancel && i < fmls.size(); ++i) {
for (unsigned i = 0; m.limit().inc() && i < fmls.size(); ++i) {
m_subst.apply(2, deltas, expr_offset(fmls[i].get(), 0), q);
fmls[i] = q;
}
@ -677,7 +664,7 @@ namespace tb {
}
}
m_rw.mk_and(fmls.size(), fmls.c_ptr(), postcond);
if (m_cancel) {
if (!m.limit().inc()) {
return false;
}
if (m.is_false(postcond)) {
@ -1350,7 +1337,6 @@ namespace datalog {
unsigned m_seqno;
tb::instruction m_instruction;
lbool m_status;
volatile bool m_cancel;
stats m_stats;
uint_set m_displayed_rules;
public:
@ -1365,8 +1351,7 @@ namespace datalog {
m_rules(),
m_seqno(0),
m_instruction(tb::SELECT_PREDICATE),
m_status(l_undef),
m_cancel(false)
m_status(l_undef)
{
// m_fparams.m_relevancy_lvl = 0;
m_fparams.m_mbqi = false;
@ -1393,18 +1378,9 @@ namespace datalog {
IF_VERBOSE(1, display_clause(*get_clause(), verbose_stream() << "g" << get_clause()->get_seqno() << " "););
return run();
}
void cancel() {
m_cancel = true;
m_index.cleanup();
m_solver.cancel();
}
void cleanup() {
m_cancel = false;
m_clauses.reset();
m_index.cleanup();
m_solver.reset_cancel();
}
void reset_statistics() {
@ -1519,7 +1495,7 @@ namespace datalog {
m_status = l_undef;
while (true) {
IF_VERBOSE(2, verbose_stream() << m_instruction << "\n";);
if (m_cancel) {
if (!m.limit().inc()) {
cleanup();
return l_undef;
}
@ -1671,9 +1647,6 @@ namespace datalog {
lbool tab::query(expr* query) {
return m_imp->query(query);
}
void tab::cancel() {
m_imp->cancel();
}
void tab::cleanup() {
m_imp->cleanup();
}

View file

@ -34,7 +34,6 @@ namespace datalog {
tab(context& ctx);
~tab();
virtual lbool query(expr* query);
virtual void cancel();
virtual void cleanup();
virtual void reset_statistics();
virtual void collect_statistics(statistics& st) const;

View file

@ -50,8 +50,7 @@ namespace datalog {
rm(ctx.get_rule_manager()),
m_inner_ctx(m, ctx.get_register_engine(), ctx.get_fparams()),
a(m),
m_pinned(m),
m_cancel(false) {
m_pinned(m) {
params_ref params;
params.set_sym("default_relation", symbol("karr_relation"));
params.set_sym("engine", symbol("datalog"));
@ -189,11 +188,6 @@ namespace datalog {
}
}
};
void mk_karr_invariants::cancel() {
m_cancel = true;
m_inner_ctx.cancel();
}
rule_set * mk_karr_invariants::operator()(rule_set const & source) {
if (!m_ctx.karr()) {
@ -214,7 +208,7 @@ namespace datalog {
get_invariants(*src_loop);
if (m_cancel) {
if (!m.limit().inc()) {
return 0;
}

View file

@ -57,7 +57,6 @@ namespace datalog {
arith_util a;
obj_map<func_decl, expr*> m_fun2inv;
ast_ref_vector m_pinned;
volatile bool m_cancel;
void get_invariants(rule_set const& src);
@ -67,8 +66,6 @@ namespace datalog {
mk_karr_invariants(context & ctx, unsigned priority);
virtual ~mk_karr_invariants();
virtual void cancel();
rule_set * operator()(rule_set const & source);