3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-28 11:25:51 +00:00

Merge pull request #373 from NikolajBjorner/master

revamp cancellation logic
This commit is contained in:
Nikolaj Bjorner 2015-12-12 10:34:13 -08:00
commit 3ff7283f94
228 changed files with 545 additions and 1851 deletions

View file

@ -372,7 +372,7 @@ extern "C" {
}
scoped_anum_vector roots(_am);
{
cancel_eh<algebraic_numbers::manager> eh(_am);
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
api::context::set_interruptable si(*(mk_c(c)), eh);
scoped_timer timer(mk_c(c)->params().m_timeout, &eh);
vector_var2anum v2a(as);
@ -407,7 +407,7 @@ extern "C" {
return 0;
}
{
cancel_eh<algebraic_numbers::manager> eh(_am);
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
api::context::set_interruptable si(*(mk_c(c)), eh);
scoped_timer timer(mk_c(c)->params().m_timeout, &eh);
vector_var2anum v2a(as);

View file

@ -671,7 +671,7 @@ extern "C" {
bool use_ctrl_c = p.get_bool("ctrl_c", false);
th_rewriter m_rw(m, p);
expr_ref result(m);
cancel_eh<th_rewriter> eh(m_rw);
cancel_eh<reslimit> eh(m.limit());
api::context::set_interruptable si(*(mk_c(c)), eh);
{
scoped_ctrl_c ctrlc(eh, false, use_ctrl_c);

View file

@ -75,7 +75,8 @@ namespace api {
m_dtutil(m()),
m_last_result(m()),
m_ast_trail(m()),
m_replay_stack() {
m_replay_stack(),
m_pmanager(m_limit) {
m_error_code = Z3_OK;
m_print_mode = Z3_PRINT_SMTLIB_FULL;
@ -122,9 +123,8 @@ namespace api {
{
if (m_interruptable)
(*m_interruptable)();
m().set_cancel(true);
if (m_rcf_manager.get() != 0)
m_rcf_manager->set_cancel(true);
m_limit.cancel();
m().limit().cancel();
}
}
@ -323,7 +323,7 @@ namespace api {
// -----------------------
realclosure::manager & context::rcfm() {
if (m_rcf_manager.get() == 0) {
m_rcf_manager = alloc(realclosure::manager, m_rcf_qm);
m_rcf_manager = alloc(realclosure::manager, m_limit, m_rcf_qm);
}
return *(m_rcf_manager.get());
}

View file

@ -187,9 +187,11 @@ namespace api {
//
// -----------------------
private:
reslimit m_limit;
pmanager m_pmanager;
public:
polynomial::manager & pm() { return m_pmanager.pm(); }
reslimit & poly_limit() { return m_limit; }
// ------------------------
//

View file

@ -130,12 +130,6 @@ namespace api {
m_context.display_smt2(num_queries, queries, str);
return str.str();
}
void cancel() {
m_context.cancel();
}
void reset_cancel() {
m_context.reset_cancel();
}
unsigned get_num_levels(func_decl* pred) {
return m_context.get_num_levels(pred);
}
@ -285,13 +279,13 @@ extern "C" {
LOG_Z3_fixedpoint_query(c, d, q);
RESET_ERROR_CODE();
lbool r = l_undef;
cancel_eh<api::fixedpoint_context> eh(*to_fixedpoint_ref(d));
unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
unsigned rlimit = to_fixedpoint(d)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit());
api::context::set_interruptable si(*(mk_c(c)), eh);
{
scoped_timer timer(timeout, &eh);
scoped_rlimit _rlimit(mk_c(c)->m().limit(), rlimit);
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
api::context::set_interruptable si(*(mk_c(c)), eh);
scoped_timer timer(timeout, &eh);
try {
r = to_fixedpoint_ref(d)->ctx().query(to_expr(q));
}
@ -313,7 +307,7 @@ extern "C" {
RESET_ERROR_CODE();
lbool r = l_undef;
unsigned timeout = to_fixedpoint(d)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
cancel_eh<api::fixedpoint_context> eh(*to_fixedpoint_ref(d));
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
api::context::set_interruptable si(*(mk_c(c)), eh);
{
scoped_timer timer(timeout, &eh);

View file

@ -260,7 +260,7 @@ extern "C" {
unsigned timeout = to_params(p)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
unsigned rlimit = to_params(p)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit());
bool use_ctrl_c = to_params(p)->m_params.get_bool("ctrl_c", false);
cancel_eh<solver> eh(*m_solver.get());
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
api::context::set_interruptable si(*(mk_c(c)), eh);
ast *_pat = to_ast(pat);

View file

@ -124,7 +124,7 @@ extern "C" {
LOG_Z3_optimize_check(c, o);
RESET_ERROR_CODE();
lbool r = l_undef;
cancel_eh<opt::context> eh(*to_optimize_ptr(o));
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
unsigned timeout = to_optimize_ptr(o)->get_params().get_uint("timeout", mk_c(c)->get_timeout());
unsigned rlimit = mk_c(c)->get_rlimit();
api::context::set_interruptable si(*(mk_c(c)), eh);

View file

@ -29,17 +29,13 @@ Notes:
namespace api {
pmanager::pmanager():
m_pm(m_nm) {
pmanager::pmanager(reslimit& lim):
m_pm(lim, m_nm) {
}
pmanager::~pmanager() {
}
void pmanager::set_cancel(bool f) {
m_pm.set_cancel(f);
}
};
extern "C" {
@ -65,8 +61,9 @@ extern "C" {
polynomial_ref_vector rs(pm);
polynomial_ref r(pm);
expr_ref _r(mk_c(c)->m());
{
cancel_eh<polynomial::manager> eh(pm);
cancel_eh<reslimit> eh(mk_c(c)->poly_limit());
api::context::set_interruptable si(*(mk_c(c)), eh);
scoped_timer timer(mk_c(c)->params().m_timeout, &eh);
pm.psc_chain(_p, _q, v_x, rs);

View file

@ -28,10 +28,9 @@ namespace api {
polynomial::manager m_pm;
// TODO: add support for caching expressions -> polynomial and back
public:
pmanager();
pmanager(reslimit& limx);
virtual ~pmanager();
polynomial::manager & pm() { return m_pm; }
void set_cancel(bool f);
};
};

View file

@ -30,7 +30,7 @@ static rcmanager & rcfm(Z3_context c) {
}
static void reset_rcf_cancel(Z3_context c) {
rcfm(c).reset_cancel();
// no-op
}
static Z3_rcf_num from_rcnumeral(rcnumeral a) {

View file

@ -271,7 +271,7 @@ extern "C" {
unsigned timeout = to_solver(s)->m_params.get_uint("timeout", mk_c(c)->get_timeout());
unsigned rlimit = to_solver(s)->m_params.get_uint("rlimit", mk_c(c)->get_rlimit());
bool use_ctrl_c = to_solver(s)->m_params.get_bool("ctrl_c", false);
cancel_eh<solver> eh(*to_solver_ref(s));
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
api::context::set_interruptable si(*(mk_c(c)), eh);
lbool result;
{

View file

@ -409,7 +409,7 @@ extern "C" {
unsigned timeout = p.get_uint("timeout", UINT_MAX);
bool use_ctrl_c = p.get_bool("ctrl_c", false);
cancel_eh<tactic> eh(*to_tactic_ref(t));
cancel_eh<reslimit> eh(mk_c(c)->m().limit());
to_tactic_ref(t)->updt_params(p);

View file

@ -28,8 +28,8 @@ struct arith_decl_plugin::algebraic_numbers_wrapper {
id_gen m_id_gen;
scoped_anum_vector m_nums;
algebraic_numbers_wrapper():
m_amanager(m_qmanager),
algebraic_numbers_wrapper(reslimit& lim):
m_amanager(lim, m_qmanager),
m_nums(m_amanager) {
}
@ -66,7 +66,7 @@ struct arith_decl_plugin::algebraic_numbers_wrapper {
arith_decl_plugin::algebraic_numbers_wrapper & arith_decl_plugin::aw() const {
if (m_aw == 0)
const_cast<arith_decl_plugin*>(this)->m_aw = alloc(algebraic_numbers_wrapper);
const_cast<arith_decl_plugin*>(this)->m_aw = alloc(algebraic_numbers_wrapper, m_manager->limit());
return *m_aw;
}
@ -110,10 +110,6 @@ parameter arith_decl_plugin::translate(parameter const & p, decl_plugin & target
return parameter(_target.aw().mk_id(aw().idx2anum(p.get_ext_id())), true);
}
void arith_decl_plugin::set_cancel(bool f) {
if (m_aw)
m_aw->m_amanager.set_cancel(f);
}
void arith_decl_plugin::set_manager(ast_manager * m, family_id id) {
decl_plugin::set_manager(m, id);

View file

@ -211,7 +211,6 @@ public:
virtual expr * get_some_value(sort * s);
virtual void set_cancel(bool f);
};
/**
@ -398,9 +397,6 @@ public:
return m_manager.mk_eq(lhs, rhs);
}
void set_cancel(bool f) {
plugin().set_cancel(f);
}
};
#endif /* ARITH_DECL_PLUGIN_H_ */

View file

@ -1433,12 +1433,6 @@ ast_manager::~ast_manager() {
}
}
void ast_manager::set_cancel(bool f) {
for (unsigned i = 0; i < m_plugins.size(); i++) {
m_plugins[i]->set_cancel(f);
}
}
void ast_manager::compact_memory() {
m_alloc.consolidate();
unsigned capacity = m_ast_table.capacity();

View file

@ -932,7 +932,6 @@ public:
virtual ~decl_plugin() {}
virtual void finalize() {}
virtual void set_cancel(bool f) {}
virtual decl_plugin * mk_fresh() = 0;
@ -1472,9 +1471,6 @@ public:
~ast_manager();
// propagate cancellation signal to decl_plugins
void set_cancel(bool f);
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
bool has_trace_stream() const { return m_trace_stream != 0; }
std::ostream & trace_stream() { SASSERT(has_trace_stream()); return *m_trace_stream; }
@ -1522,6 +1518,7 @@ public:
}
reslimit& limit() { return m_limit; }
bool canceled() { return !limit().inc(); }
void register_plugin(symbol const & s, decl_plugin * plugin);

View file

@ -87,9 +87,6 @@ public:
TRACE("name_exprs", tout << mk_ismt2_pp(n, m_rw.m()) << "\n---->\n" << mk_ismt2_pp(r, m_rw.m()) << "\n";);
}
virtual void set_cancel(bool f) {
m_rw.set_cancel(f);
}
virtual void reset() {
m_rw.reset();

View file

@ -37,9 +37,6 @@ public:
proof_ref & p // [OUT] proof for (iff n p)
) = 0;
virtual void set_cancel(bool f) = 0;
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
virtual void reset() = 0;
};

View file

@ -250,7 +250,6 @@ struct nnf::imp {
name_exprs * m_name_nested_formulas;
name_exprs * m_name_quant;
volatile bool m_cancel;
unsigned long long m_max_memory; // in bytes
imp(ast_manager & m, defined_names & n, params_ref const & p):
@ -259,8 +258,7 @@ struct nnf::imp {
m_todo_defs(m),
m_todo_proofs(m),
m_result_pr_stack(m),
m_skolemizer(m),
m_cancel(false) {
m_skolemizer(m) {
updt_params(p);
for (unsigned i = 0; i < 4; i++) {
m_cache[i] = alloc(act_cache, m);
@ -369,15 +367,12 @@ struct nnf::imp {
return false;
}
void set_cancel(bool f) {
m_cancel = f;
}
void checkpoint() {
cooperate("nnf");
if (memory::get_allocation_size() > m_max_memory)
throw nnf_exception(Z3_MAX_MEMORY_MSG);
if (m_cancel)
if (m().canceled())
throw nnf_exception(Z3_CANCELED_MSG);
}
@ -916,9 +911,6 @@ void nnf::get_param_descrs(param_descrs & r) {
imp::get_param_descrs(r);
}
void nnf::set_cancel(bool f) {
m_imp->set_cancel(f);
}
void nnf::reset() {
m_imp->reset();

View file

@ -44,10 +44,6 @@ public:
*/
static void get_param_descrs(param_descrs & r);
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
void set_cancel(bool f);
void reset();
void reset_cache();
};

View file

@ -1032,9 +1032,6 @@ br_status arith_rewriter::mk_abs_core(expr * arg, expr_ref & result) {
return BR_REWRITE2;
}
void arith_rewriter::set_cancel(bool f) {
m_util.set_cancel(f);
}
// Return true if t is of the form c*Pi where c is a numeral.
// Store c into k

View file

@ -167,8 +167,6 @@ public:
}
br_status mk_is_int(expr * arg, expr_ref & result);
void set_cancel(bool f);
br_status mk_sin_core(expr * arg, expr_ref & result);
br_status mk_cos_core(expr * arg, expr_ref & result);
br_status mk_tan_core(expr * arg, expr_ref & result);

View file

@ -649,10 +649,6 @@ void bit_blaster_rewriter::updt_params(params_ref const& p) {
m_imp->m_cfg.updt_params(p);
}
void bit_blaster_rewriter::set_cancel(bool f) {
m_imp->set_cancel(f);
m_imp->m_blaster.set_cancel(f);
}
void bit_blaster_rewriter::push() {
m_imp->push();

View file

@ -30,7 +30,6 @@ public:
bit_blaster_rewriter(ast_manager & m, params_ref const & p);
~bit_blaster_rewriter();
void updt_params(params_ref const & p);
void set_cancel(bool f);
ast_manager & m() const;
unsigned get_num_steps() const;
void cleanup();

View file

@ -36,7 +36,6 @@ protected:
void mk_ext_rotate_left_right(unsigned sz, expr * const * a_bits, expr * const * b_bits, expr_ref_vector & out_bits);
unsigned long long m_max_memory;
volatile bool m_cancel;
bool m_use_wtm; /* Wallace Tree Multiplier */
bool m_use_bcm; /* Booth Multiplier for constants */
void checkpoint();
@ -45,7 +44,6 @@ public:
bit_blaster_tpl(Cfg const & cfg = Cfg(), unsigned long long max_memory = UINT64_MAX, bool use_wtm = false, bool use_bcm=false):
Cfg(cfg),
m_max_memory(max_memory),
m_cancel(false),
m_use_wtm(use_wtm),
m_use_bcm(use_bcm) {
}
@ -54,9 +52,6 @@ public:
m_max_memory = max_memory;
}
void set_cancel(bool f) { m_cancel = f; }
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
// Cfg required API
ast_manager & m() const { return Cfg::m(); }

View file

@ -27,7 +27,7 @@ template<typename Cfg>
void bit_blaster_tpl<Cfg>::checkpoint() {
if (memory::get_allocation_size() > m_max_memory)
throw rewriter_exception(Z3_MAX_MEMORY_MSG);
if (m_cancel)
if (m().canceled())
throw rewriter_exception(Z3_CANCELED_MSG);
cooperate("bit-blaster");
}

View file

@ -444,12 +444,6 @@ void der_rewriter::operator()(expr * t, expr_ref & result, proof_ref & result_pr
m_imp->operator()(t, result, result_pr);
}
void der_rewriter::set_cancel(bool f) {
#pragma omp critical (der_rewriter)
{
m_imp->set_cancel(f);
}
}
void der_rewriter::cleanup() {
ast_manager & m = m_imp->m();

View file

@ -174,9 +174,6 @@ public:
void operator()(expr * t, expr_ref & result, proof_ref & result_pr);
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
void set_cancel(bool f);
void cleanup();
void reset();
};

View file

@ -107,9 +107,6 @@ public:
}
}
virtual void set_cancel(bool f) {
m_replacer.set_cancel(f);
}
virtual unsigned get_num_steps() const {
return m_replacer.get_num_steps();
@ -146,10 +143,6 @@ public:
m_r.reset_used_dependencies();
}
virtual void set_cancel(bool f) {
m_r.set_cancel(f);
}
virtual unsigned get_num_steps() const {
return m_r.get_num_steps();
}

View file

@ -39,9 +39,6 @@ public:
virtual void operator()(expr * t, expr_ref & result);
virtual void operator()(expr_ref & t) { expr_ref s(t, m()); (*this)(s, t); }
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
virtual void set_cancel(bool f) = 0;
virtual unsigned get_num_steps() const { return 0; }
virtual void reset() = 0;

View file

@ -212,7 +212,6 @@ protected:
};
Config & m_cfg;
unsigned m_num_steps;
volatile bool m_cancel;
ptr_vector<expr> m_bindings;
var_shifter m_shifter;
expr_ref m_r;
@ -333,10 +332,6 @@ public:
Config & cfg() { return m_cfg; }
Config const & cfg() const { return m_cfg; }
void set_cancel(bool f) { m_cancel = f; }
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
~rewriter_tpl();
void reset();

View file

@ -495,7 +495,6 @@ rewriter_tpl<Config>::rewriter_tpl(ast_manager & m, bool proof_gen, Config & cfg
rewriter_core(m, proof_gen),
m_cfg(cfg),
m_num_steps(0),
m_cancel(false),
m_shifter(m),
m_r(m),
m_pr(m),
@ -576,10 +575,9 @@ template<bool ProofGen>
void rewriter_tpl<Config>::resume_core(expr_ref & result, proof_ref & result_pr) {
SASSERT(!frame_stack().empty());
while (!frame_stack().empty()) {
if (m_cancel)
throw rewriter_exception(Z3_CANCELED_MSG);
if (!m().limit().inc())
throw rewriter_exception(Z3_MAX_RESOURCE_MSG);
if (m().canceled()) {
throw rewriter_exception(m().limit().get_cancel_msg());
}
SASSERT(!ProofGen || result_stack().size() == result_pr_stack().size());
frame & fr = frame_stack().back();
expr * t = fr.m_curr;

View file

@ -214,7 +214,7 @@ br_status seq_rewriter::mk_seq_contains(expr* a, expr* b, expr_ref& result) {
for (unsigned i = 0; !found && i < as.size(); ++i) {
if (bs.size() > as.size() - i) break;
unsigned j = 0;
for (; j < bs.size() && as[j] == bs[i+j]; ++j) {};
for (; j < bs.size() && as[j+i] == bs[j]; ++j) {};
found = j == bs.size();
}
if (found) {

View file

@ -685,9 +685,6 @@ struct th_rewriter_cfg : public default_rewriter_cfg {
return false;
}
void set_cancel(bool f) {
m_a_rw.set_cancel(f);
}
};
template class rewriter_tpl<th_rewriter_cfg>;
@ -734,21 +731,11 @@ unsigned th_rewriter::get_num_steps() const {
return m_imp->get_num_steps();
}
void th_rewriter::set_cancel(bool f) {
#pragma omp critical (th_rewriter)
{
m_imp->set_cancel(f);
m_imp->cfg().set_cancel(f);
}
}
void th_rewriter::cleanup() {
ast_manager & m = m_imp->m();
#pragma omp critical (th_rewriter)
{
dealloc(m_imp);
m_imp = alloc(imp, m, m_params);
}
dealloc(m_imp);
m_imp = alloc(imp, m, m_params);
}
void th_rewriter::reset() {

View file

@ -45,9 +45,6 @@ public:
void operator()(expr * t, expr_ref & result, proof_ref & result_pr);
void operator()(expr * n, unsigned num_bindings, expr * const * bindings, expr_ref & result);
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
void set_cancel(bool f);
void cleanup();
void reset();

View file

@ -352,16 +352,14 @@ cmd_context::~cmd_context() {
}
void cmd_context::set_cancel(bool f) {
if (m_solver) {
if (has_manager()) {
if (f) {
m_solver->cancel();
m().limit().cancel();
}
else {
m_solver->reset_cancel();
m().limit().reset_cancel();
}
}
if (has_manager())
m().set_cancel(f);
}
opt_wrapper* cmd_context::get_opt() {
@ -1418,7 +1416,7 @@ void cmd_context::check_sat(unsigned num_assumptions, expr * const * assumptions
if (m_opt && !m_opt->empty()) {
was_opt = true;
m_check_sat_result = get_opt();
cancel_eh<opt_wrapper> eh(*get_opt());
cancel_eh<reslimit> eh(m().limit());
scoped_ctrl_c ctrlc(eh);
scoped_timer timer(timeout, &eh);
scoped_rlimit _rlimit(m().limit(), rlimit);
@ -1453,7 +1451,7 @@ void cmd_context::check_sat(unsigned num_assumptions, expr * const * assumptions
else if (m_solver) {
m_check_sat_result = m_solver.get(); // solver itself stores the result.
m_solver->set_progress_callback(this);
cancel_eh<solver> eh(*m_solver);
cancel_eh<reslimit> eh(m().limit());
scoped_ctrl_c ctrlc(eh);
scoped_timer timer(timeout, &eh);
scoped_rlimit _rlimit(m().limit(), rlimit);
@ -1612,7 +1610,8 @@ void cmd_context::validate_model() {
model_evaluator evaluator(*(md.get()), p);
contains_array_op_proc contains_array(m());
{
cancel_eh<model_evaluator> eh(evaluator);
scoped_rlimit _rlimit(m().limit(), 0);
cancel_eh<reslimit> eh(m().limit());
expr_ref r(m());
scoped_ctrl_c ctrlc(eh);
ptr_vector<expr>::const_iterator it = begin_assertions();

View file

@ -116,9 +116,6 @@ public:
virtual bool empty() = 0;
virtual void push() = 0;
virtual void pop(unsigned n) = 0;
virtual void set_cancel(bool f) = 0;
virtual void reset_cancel() = 0;
virtual void cancel() = 0;
virtual lbool optimize() = 0;
virtual void set_hard_constraints(ptr_vector<expr> & hard) = 0;
virtual void display_assignment(std::ostream& out) = 0;

View file

@ -35,7 +35,7 @@ context_params::context_params() {
m_smtlib2_compliant = false;
m_well_sorted_check = false;
m_timeout = UINT_MAX;
m_rlimit = UINT_MAX;
m_rlimit = 0;
updt_params();
}
@ -153,7 +153,7 @@ void context_params::updt_params(params_ref const & p) {
void context_params::collect_param_descrs(param_descrs & d) {
d.insert("timeout", CPK_UINT, "default timeout (in milliseconds) used for solvers", "4294967295");
d.insert("rlimit", CPK_UINT, "default resource limit used for solvers", "4294967295");
d.insert("rlimit", CPK_UINT, "default resource limit used for solvers. Unrestricted when set to 0.", "0");
d.insert("well_sorted_check", CPK_BOOL, "type checker", "false");
d.insert("type_check", CPK_BOOL, "type checker (alias for well_sorted_check)", "true");
d.insert("auto_config", CPK_BOOL, "use heuristics to automatically select solver and configure it", "true");

View file

@ -63,11 +63,13 @@ public:
last_result->get_model(md);
expr_ref r(ctx.m());
unsigned timeout = m_params.get_uint("timeout", UINT_MAX);
unsigned rlimit = m_params.get_uint("rlimit", 0);
model_evaluator ev(*(md.get()), m_params);
cancel_eh<model_evaluator> eh(ev);
cancel_eh<reslimit> eh(ctx.m().limit());
{
scoped_ctrl_c ctrlc(eh);
scoped_timer timer(timeout, &eh);
scoped_rlimit _rlimit(ctx.m().limit(), rlimit);
cmd_context::scoped_watch sw(ctx);
try {
ev(m_target, r);

View file

@ -33,7 +33,7 @@ Notes:
static void to_poly(cmd_context & ctx, expr * t) {
polynomial::numeral_manager nm;
polynomial::manager pm(nm);
polynomial::manager pm(ctx.m().limit(), nm);
default_expr2polynomial expr2poly(ctx.m(), pm);
polynomial::polynomial_ref p(pm);
polynomial::scoped_numeral d(nm);
@ -52,7 +52,7 @@ static void to_poly(cmd_context & ctx, expr * t) {
static void factor(cmd_context & ctx, expr * t, polynomial::factor_params const & ps) {
polynomial::numeral_manager nm;
polynomial::manager pm(nm);
polynomial::manager pm(ctx.m().limit(), nm);
default_expr2polynomial expr2poly(ctx.m(), pm);
polynomial::polynomial_ref p(pm);
polynomial::scoped_numeral d(nm);
@ -83,6 +83,7 @@ static void factor(cmd_context & ctx, expr * t, polynomial::factor_params const
class poly_isolate_roots_cmd : public cmd {
struct context {
arith_util m_util;
reslimit m_lim;
unsynch_mpq_manager m_qm;
polynomial::manager m_pm;
algebraic_numbers::manager m_am;
@ -94,8 +95,8 @@ class poly_isolate_roots_cmd : public cmd {
context(ast_manager & m):
m_util(m),
m_pm(m_qm),
m_am(m_qm),
m_pm(m.limit(), m_qm),
m_am(m_lim, m_qm),
m_p(m_pm),
m_expr2poly(m, m_pm),
m_var(polynomial::null_var),

View file

@ -27,7 +27,7 @@ static void to_subpaving(cmd_context & ctx, expr * t) {
ast_manager & m = ctx.m();
unsynch_mpq_manager qm;
scoped_ptr<subpaving::context> s;
s = subpaving::mk_mpq_context(qm);
s = subpaving::mk_mpq_context(ctx.m().limit(), qm);
expr2var e2v(m);
expr2subpaving e2s(m, *s, &e2v);
params_ref p;

View file

@ -73,9 +73,11 @@ public:
unsigned cache_sz;
unsigned num_steps = 0;
unsigned timeout = m_params.get_uint("timeout", UINT_MAX);
unsigned rlimit = m_params.get_uint("rlimit", UINT_MAX);
bool failed = false;
cancel_eh<th_rewriter> eh(s);
cancel_eh<reslimit> eh(ctx.m().limit());
{
scoped_rlimit _rlimit(ctx.m().limit(), rlimit);
scoped_ctrl_c ctrlc(eh);
scoped_timer timer(timeout, &eh);
cmd_context::scoped_watch sw(ctx);

View file

@ -188,6 +188,7 @@ public:
tref->set_logic(ctx.get_logic());
ast_manager & m = ctx.m();
unsigned timeout = p.get_uint("timeout", UINT_MAX);
unsigned rlimit = p.get_uint("rlimit", 0);
goal_ref g = alloc(goal, m, ctx.produce_proofs(), ctx.produce_models(), ctx.produce_unsat_cores());
assert_exprs_from(ctx, *g);
TRACE("check_sat_using", g->display(tout););
@ -199,8 +200,9 @@ public:
ctx.set_check_sat_result(result.get());
{
tactic & t = *tref;
cancel_eh<tactic> eh(t);
cancel_eh<reslimit> eh(m.limit());
{
scoped_rlimit _rlimit(m.limit(), rlimit);
scoped_ctrl_c ctrlc(eh);
scoped_timer timer(timeout, &eh);
cmd_context::scoped_watch sw(ctx);
@ -302,6 +304,7 @@ public:
assert_exprs_from(ctx, *g);
unsigned timeout = p.get_uint("timeout", UINT_MAX);
unsigned rlimit = p.get_uint("rlimit", 0);
goal_ref_buffer result_goals;
model_converter_ref mc;
@ -310,8 +313,9 @@ public:
std::string reason_unknown;
bool failed = false;
cancel_eh<tactic> eh(t);
cancel_eh<reslimit> eh(m.limit());
{
scoped_rlimit _rlimit(m.limit(), rlimit);
scoped_ctrl_c ctrlc(eh);
scoped_timer timer(timeout, &eh);
cmd_context::scoped_watch sw(ctx);

View file

@ -936,8 +936,7 @@ namespace Duality {
void cancel(){
scoped_proof_mode spm(m(),m_mode);
canceled = true;
if(m_solver)
m_solver->cancel();
m().limit().cancel();
}
unsigned get_scope_level(){ scoped_proof_mode spm(m(),m_mode); return m_solver->get_scope_level();}

View file

@ -98,7 +98,6 @@ struct euclidean_solver::imp {
numeral_manager * m_manager;
bool m_owns_m;
volatile bool m_cancel;
equations m_equations;
equations m_solution;
@ -517,7 +516,6 @@ struct euclidean_solver::imp {
m_var_queue(16, elim_order_lt(m_solved)) {
m_inconsistent = null_eq_idx;
m_next_justification = 0;
m_cancel = false;
m_next_x = null_var;
m_next_eq = null_eq_idx;
}
@ -779,9 +777,6 @@ struct euclidean_solver::imp {
del_nums(m_norm_bs_vector);
}
void set_cancel(bool f) {
m_cancel = f;
}
};
@ -801,12 +796,9 @@ void euclidean_solver::reset() {
numeral_manager * m = m_imp->m_manager;
bool owns_m = m_imp->m_owns_m;
m_imp->m_owns_m = false;
#pragma omp critical (euclidean_solver)
{
dealloc(m_imp);
m_imp = alloc(imp, m);
m_imp->m_owns_m = owns_m;
}
dealloc(m_imp);
m_imp = alloc(imp, m);
m_imp->m_owns_m = owns_m;
}
euclidean_solver::var euclidean_solver::mk_var() {
@ -842,12 +834,6 @@ void euclidean_solver::normalize(unsigned num, mpz const * as, var const * xs, m
return m_imp->normalize(num, as, xs, c, a_prime, c_prime, js);
}
void euclidean_solver::set_cancel(bool f) {
#pragma omp critical (euclidean_solver)
{
m_imp->set_cancel(f);
}
}
void euclidean_solver::display(std::ostream & out) const {
m_imp->display(out);

View file

@ -95,10 +95,6 @@ public:
*/
void normalize(unsigned num, mpz const * as, var const * xs, mpz const & c, mpz & a_prime, mpz & c_prime, justification_vector & js);
/**
\brief Set/Reset the cancel flag.
*/
void set_cancel(bool f);
void display(std::ostream & out) const;
};

View file

@ -647,8 +647,8 @@ private:
};
hilbert_basis::hilbert_basis():
m_cancel(false),
hilbert_basis::hilbert_basis(reslimit& lim):
m_limit(lim),
m_use_support(true),
m_use_ordered_support(true),
m_use_ordered_subsumption(true)
@ -804,7 +804,7 @@ void hilbert_basis::add_unit_vector(unsigned i, numeral const& e) {
lbool hilbert_basis::saturate() {
init_basis();
m_current_ineq = 0;
while (!m_cancel && m_current_ineq < m_ineqs.size()) {
while (checkpoint() && m_current_ineq < m_ineqs.size()) {
select_inequality();
stopwatch sw;
sw.start();
@ -823,7 +823,7 @@ lbool hilbert_basis::saturate() {
}
++m_current_ineq;
}
if (m_cancel) {
if (!checkpoint()) {
return l_undef;
}
return l_true;
@ -853,7 +853,7 @@ lbool hilbert_basis::saturate_orig(num_vector const& ineq, bool is_eq) {
// resolve passive into active
offset_t j = alloc_vector();
while (!m_passive->empty()) {
if (m_cancel) {
if (!checkpoint()) {
return l_undef;
}
offset_t idx = m_passive->pop();
@ -862,7 +862,7 @@ lbool hilbert_basis::saturate_orig(num_vector const& ineq, bool is_eq) {
recycle(idx);
continue;
}
for (unsigned i = 0; !m_cancel && i < m_active.size(); ++i) {
for (unsigned i = 0; checkpoint() && i < m_active.size(); ++i) {
if ((!m_use_support || support.contains(m_active[i].m_offset)) && can_resolve(idx, m_active[i], true)) {
resolve(idx, m_active[i], j);
if (add_goal(j)) {
@ -942,7 +942,7 @@ lbool hilbert_basis::saturate(num_vector const& ineq, bool is_eq) {
TRACE("hilbert_basis", display(tout););
// resolve passive into active
offset_t idx = alloc_vector();
while (!m_cancel && !m_passive2->empty()) {
while (checkpoint() && !m_passive2->empty()) {
offset_t sos, pas;
TRACE("hilbert_basis", display(tout); );
unsigned offset = m_passive2->pop(sos, pas);
@ -967,7 +967,7 @@ lbool hilbert_basis::saturate(num_vector const& ineq, bool is_eq) {
}
idx = alloc_vector();
}
if (m_cancel) {
if (!checkpoint()) {
return l_undef;
}
@ -1112,6 +1112,10 @@ hilbert_basis::offset_t hilbert_basis::alloc_vector() {
}
}
bool hilbert_basis::checkpoint() {
return m_limit.inc();
}
bool hilbert_basis::add_goal(offset_t idx) {
TRACE("hilbert_basis", display(tout, idx););
values v = vec(idx);

View file

@ -32,6 +32,7 @@ Revision History:
#include "lbool.h"
#include "statistics.h"
#include "checked_int64.h"
#include "rlimit.h"
typedef vector<rational> rational_vector;
@ -85,6 +86,7 @@ class hilbert_basis {
numeral const* operator()() const { return m_values; }
};
reslimit& m_limit;
vector<num_vector> m_ineqs; // set of asserted inequalities
svector<bool> m_iseq; // inequalities that are equalities
num_vector m_store; // store of vectors
@ -95,7 +97,6 @@ class hilbert_basis {
svector<offset_t> m_zero; // zeros
passive* m_passive; // passive set
passive2* m_passive2; // passive set
volatile bool m_cancel;
stats m_stats;
index* m_index; // index of generated vectors
unsigned_vector m_ints; // indices that can be both positive and negative
@ -105,6 +106,7 @@ class hilbert_basis {
bool m_use_ordered_support; // parameter: (commutativity) resolve in order
bool m_use_ordered_subsumption; // parameter
class iterator {
hilbert_basis const& hb;
unsigned m_idx;
@ -138,6 +140,8 @@ class hilbert_basis {
bool can_resolve(offset_t i, offset_t j, bool check_sign) const;
sign_t get_sign(offset_t idx) const;
bool add_goal(offset_t idx);
bool checkpoint();
offset_t alloc_vector();
void resolve(offset_t i, offset_t j, offset_t r);
iterator begin() const { return iterator(*this,0); }
@ -154,7 +158,7 @@ class hilbert_basis {
public:
hilbert_basis();
hilbert_basis(reslimit& rl);
~hilbert_basis();
void reset();
@ -188,8 +192,6 @@ public:
unsigned get_num_ineqs() const { return m_ineqs.size(); }
void get_ge(unsigned i, rational_vector& v, rational& b, bool& is_eq);
void set_cancel(bool f) { m_cancel = f; }
void display(std::ostream& out) const;
void collect_statistics(statistics& st) const;

View file

@ -21,6 +21,7 @@ Revision History:
#include"mpq.h"
#include"ext_numeral.h"
#include"rlimit.h"
/**
\brief Default configuration for interval manager.
@ -110,6 +111,7 @@ public:
typedef typename numeral_manager::numeral numeral;
typedef typename C::interval interval;
private:
reslimit& m_limit;
C m_c;
numeral m_result_lower;
numeral m_result_upper;
@ -127,7 +129,6 @@ private:
interval m_3_pi_div_2;
interval m_2_pi;
volatile bool m_cancel;
void round_to_minus_inf() { m_c.round_to_minus_inf(); }
void round_to_plus_inf() { m_c.round_to_plus_inf(); }
@ -161,11 +162,9 @@ private:
void checkpoint();
public:
interval_manager(C const & c);
interval_manager(reslimit& lim, C const & c);
~interval_manager();
void set_cancel(bool f) { m_cancel = f; }
numeral_manager & m() const { return m_c.m(); }
void del(interval & a);

View file

@ -30,11 +30,10 @@ Revision History:
// #define TRACE_NTH_ROOT
template<typename C>
interval_manager<C>::interval_manager(C const & c):m_c(c) {
interval_manager<C>::interval_manager(reslimit& lim, C const & c): m_limit(lim), m_c(c) {
m().set(m_minus_one, -1);
m().set(m_one, 1);
m_pi_n = 0;
m_cancel = false;
}
template<typename C>
@ -63,7 +62,7 @@ void interval_manager<C>::del(interval & a) {
template<typename C>
void interval_manager<C>::checkpoint() {
if (m_cancel)
if (!m_limit.inc())
throw default_exception("canceled");
cooperate("interval");
}

View file

@ -62,6 +62,7 @@ namespace algebraic_numbers {
}
struct manager::imp {
reslimit& m_limit;
manager & m_wrapper;
small_object_allocator & m_allocator;
unsynch_mpq_manager & m_qmanager;
@ -82,7 +83,6 @@ namespace algebraic_numbers {
scoped_upoly m_add_tmp;
polynomial::var m_x;
polynomial::var m_y;
volatile bool m_cancel;
// configuration
int m_min_magnitude;
@ -96,14 +96,15 @@ namespace algebraic_numbers {
unsigned m_compare_refine;
unsigned m_compare_poly_eq;
imp(manager & w, unsynch_mpq_manager & m, params_ref const & p, small_object_allocator & a):
imp(reslimit& lim, manager & w, unsynch_mpq_manager & m, params_ref const & p, small_object_allocator & a):
m_limit(lim),
m_wrapper(w),
m_allocator(a),
m_qmanager(m),
m_bqmanager(m),
m_bqimanager(m_bqmanager),
m_pmanager(m, &a),
m_upmanager(m),
m_pmanager(lim, m, &a),
m_upmanager(lim, m),
m_is_rational_tmp(m),
m_isolate_tmp1(upm()),
m_isolate_tmp2(upm()),
@ -116,7 +117,6 @@ namespace algebraic_numbers {
m_add_tmp(upm()) {
updt_params(p);
reset_statistics();
m_cancel = false;
m_x = pm().mk_var();
m_y = pm().mk_var();
}
@ -124,14 +124,8 @@ namespace algebraic_numbers {
~imp() {
}
void set_cancel(bool f) {
m_cancel = f;
pm().set_cancel(f);
upm().set_cancel(f);
}
void checkpoint() {
if (m_cancel)
if (!m_limit.inc())
throw algebraic_exception("canceled");
cooperate("algebraic");
}
@ -2764,14 +2758,14 @@ namespace algebraic_numbers {
};
manager::manager(unsynch_mpq_manager & m, params_ref const & p, small_object_allocator * a) {
manager::manager(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p, small_object_allocator * a) {
m_own_allocator = false;
m_allocator = a;
if (m_allocator == 0) {
m_own_allocator = true;
m_allocator = alloc(small_object_allocator, "algebraic");
}
m_imp = alloc(imp, *this, m, p, *m_allocator);
m_imp = alloc(imp, lim, *this, m, p, *m_allocator);
}
manager::~manager() {
@ -2783,10 +2777,6 @@ namespace algebraic_numbers {
void manager::updt_params(params_ref const & p) {
}
void manager::set_cancel(bool f) {
m_imp->set_cancel(f);
}
unsynch_mpq_manager & manager::qm() const {
return m_imp->qm();
}

View file

@ -28,6 +28,7 @@ Notes:
#include"tptr.h"
#include"statistics.h"
#include"params.h"
#include"rlimit.h"
class small_object_allocator;
class mpbq_manager;
@ -57,16 +58,12 @@ namespace algebraic_numbers {
typedef _scoped_numeral<manager> scoped_numeral;
typedef _scoped_numeral_vector<manager> scoped_numeral_vector;
manager(unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
manager(reslimit& rl, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
~manager();
static void get_param_descrs(param_descrs & r);
static void collect_param_descrs(param_descrs & r) { get_param_descrs(r); }
void set_cancel(bool f);
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
void updt_params(params_ref const & p);
unsynch_mpq_manager & qm() const;

View file

@ -1829,6 +1829,7 @@ namespace polynomial {
typedef _scoped_numeral<numeral_manager> scoped_numeral;
typedef _scoped_numeral_vector<numeral_manager> scoped_numeral_vector;
reslimit& m_limit;
manager & m_wrapper;
numeral_manager m_manager;
up_manager m_upm;
@ -1847,7 +1848,6 @@ namespace polynomial {
unsigned_vector m_degree2pos;
bool m_use_sparse_gcd;
bool m_use_prs_gcd;
volatile bool m_cancel;
// Debugging method: check if the coefficients of p are in the numeral_manager.
bool consistent_coeffs(polynomial const * p) {
@ -2323,13 +2323,13 @@ namespace polynomial {
inc_ref(m_unit_poly);
m_use_sparse_gcd = true;
m_use_prs_gcd = false;
m_cancel = false;
}
imp(manager & w, unsynch_mpz_manager & m, monomial_manager * mm):
imp(reslimit& lim, manager & w, unsynch_mpz_manager & m, monomial_manager * mm):
m_limit(lim),
m_wrapper(w),
m_manager(m),
m_upm(m) {
m_upm(lim, m) {
if (mm == 0)
mm = alloc(monomial_manager);
m_monomial_manager = mm;
@ -2337,10 +2337,11 @@ namespace polynomial {
init();
}
imp(manager & w, unsynch_mpz_manager & m, small_object_allocator * a):
imp(reslimit& lim, manager & w, unsynch_mpz_manager & m, small_object_allocator * a):
m_limit(lim),
m_wrapper(w),
m_manager(m),
m_upm(m) {
m_upm(lim, m) {
m_monomial_manager = alloc(monomial_manager, a);
m_monomial_manager->inc_ref();
init();
@ -2371,13 +2372,8 @@ namespace polynomial {
m_monomial_manager->dec_ref();
}
void set_cancel(bool f) {
m_cancel = f;
m_upm.set_cancel(f);
}
void checkpoint() {
if (m_cancel) {
if (!m_limit.inc()) {
throw polynomial_exception("canceled");
}
cooperate("polynomial");
@ -6883,12 +6879,12 @@ namespace polynomial {
}
};
manager::manager(numeral_manager & m, monomial_manager * mm) {
m_imp = alloc(imp, *this, m, mm);
manager::manager(reslimit& lim, numeral_manager & m, monomial_manager * mm) {
m_imp = alloc(imp, lim, *this, m, mm);
}
manager::manager(numeral_manager & m, small_object_allocator * a) {
m_imp = alloc(imp, *this, m, a);
manager::manager(reslimit& lim, numeral_manager & m, small_object_allocator * a) {
m_imp = alloc(imp, lim, *this, m, a);
}
manager::~manager() {
@ -6927,10 +6923,6 @@ namespace polynomial {
return m_imp->mm().allocator();
}
void manager::set_cancel(bool f) {
m_imp->set_cancel(f);
}
void manager::add_del_eh(del_eh * eh) {
m_imp->add_del_eh(eh);
}

View file

@ -28,6 +28,7 @@ Notes:
#include"scoped_numeral_vector.h"
#include"params.h"
#include"mpbqi.h"
#include"rlimit.h"
class small_object_allocator;
@ -190,8 +191,8 @@ namespace polynomial {
private:
imp * m_imp;
public:
manager(numeral_manager & m, monomial_manager * mm = 0);
manager(numeral_manager & m, small_object_allocator * a);
manager(reslimit& lim, numeral_manager & m, monomial_manager * mm = 0);
manager(reslimit& lim, numeral_manager & m, small_object_allocator * a);
~manager();
numeral_manager & m() const;
@ -218,10 +219,6 @@ namespace polynomial {
void set_zp(numeral const & p);
void set_zp(uint64 p);
void set_cancel(bool f);
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
/**
\brief Abstract event handler.
*/

View file

@ -58,7 +58,6 @@ namespace rpolynomial {
numeral_manager & m_manager;
small_object_allocator * m_allocator;
bool m_own_allocator;
volatile bool m_cancel;
imp(manager & w, numeral_manager & m, small_object_allocator * a):
m_wrapper(w),
@ -67,7 +66,6 @@ namespace rpolynomial {
m_own_allocator(a == 0) {
if (a == 0)
m_allocator = alloc(small_object_allocator, "rpolynomial");
m_cancel = false;
}
~imp() {

View file

@ -57,8 +57,6 @@ namespace rpolynomial {
numeral_manager & m() const;
small_object_allocator & allocator() const;
void set_cancel(bool f);
/**
\brief Create a new variable.
*/

View file

@ -134,9 +134,9 @@ namespace upolynomial {
std::swap(m_total_degree, other.m_total_degree);
}
core_manager::core_manager(unsynch_mpz_manager & m):
core_manager::core_manager(reslimit& lim, unsynch_mpz_manager & m):
m_limit(lim),
m_manager(m) {
m_cancel = false;
}
core_manager::~core_manager() {
@ -153,12 +153,8 @@ namespace upolynomial {
reset(m_pw_tmp);
}
void core_manager::set_cancel(bool f) {
m_cancel = f;
}
void core_manager::checkpoint() {
if (m_cancel)
if (!m_limit.inc())
throw upolynomial_exception("canceled");
cooperate("upolynomial");
}

View file

@ -29,6 +29,7 @@ Notes:
#include"polynomial.h"
#include"z3_exception.h"
#include"mpbq.h"
#include"rlimit.h"
#define FACTOR_VERBOSE_LVL 1000
namespace upolynomial {
@ -101,6 +102,7 @@ namespace upolynomial {
};
protected:
reslimit& m_limit;
numeral_manager m_manager;
numeral_vector m_basic_tmp;
numeral_vector m_div_tmp1;
@ -114,7 +116,6 @@ namespace upolynomial {
numeral_vector m_sqf_tmp1;
numeral_vector m_sqf_tmp2;
numeral_vector m_pw_tmp;
volatile bool m_cancel;
static bool is_alias(numeral const * p, numeral_vector & buffer) { return buffer.c_ptr() != 0 && buffer.c_ptr() == p; }
void neg_core(unsigned sz1, numeral const * p1, numeral_vector & buffer);
@ -128,12 +129,12 @@ namespace upolynomial {
void CRA_combine_images(numeral_vector const & q, numeral const & p, numeral_vector & C, numeral & bound);
public:
core_manager(z_numeral_manager & m);
core_manager(reslimit& lim, z_numeral_manager & m);
~core_manager();
z_numeral_manager & zm() const { return m_manager.m(); }
numeral_manager & m() const { return const_cast<core_manager*>(this)->m_manager; }
reslimit& lim() const { return m_limit; }
/**
\brief Return true if Z_p[X]
*/
@ -156,7 +157,6 @@ namespace upolynomial {
void checkpoint();
void set_cancel(bool f);
/**
\brief set p size to 0. That is, p is the zero polynomial after this operation.
@ -576,7 +576,7 @@ namespace upolynomial {
bool factor_core(unsigned sz, numeral const * p, factors & r, factor_params const & params);
public:
manager(z_numeral_manager & m):core_manager(m) {}
manager(reslimit& lim, z_numeral_manager & m):core_manager(lim, m) {}
~manager();
void reset(numeral_vector & p) { core_manager::reset(p); }

View file

@ -518,7 +518,7 @@ bool check_hansel_lift(z_manager & upm, numeral_vector const & C,
scoped_mpz br(nm);
nm.mul(b, r, br);
zp_manager br_upm(upm.zm());
zp_manager br_upm(upm.lim(), upm.zm());
br_upm.set_zp(br);
if (A_lifted.size() != A.size()) return false;
@ -543,7 +543,7 @@ bool check_hansel_lift(z_manager & upm, numeral_vector const & C,
return false;
}
zp_manager b_upm(nm);
zp_manager b_upm(upm.lim(), nm);
b_upm.set_zp(b);
// test2: A_lifted = A (mod b)
@ -596,7 +596,7 @@ void hensel_lift(z_manager & upm, numeral const & a, numeral const & b, numeral
tout << "C = "; upm.display(tout, C); tout << ")" << endl;
);
zp_manager r_upm(nm);
zp_manager r_upm(upm.lim(), nm);
r_upm.set_zp(r);
SASSERT(upm.degree(C) == upm.degree(A) + upm.degree(B));
@ -717,7 +717,7 @@ void hensel_lift_quadratic(z_manager& upm, numeral_vector const & C,
);
// we create a new Z_p manager, since we'll be changing the input one
zp_manager zp_upm(nm);
zp_manager zp_upm(upm.lim(), nm);
zp_upm.set_zp(zpe_upm.m().p());
// get the U, V, such that A*U + B*V = 1 (mod p)
@ -1055,7 +1055,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
// the variables we'll be using and updating in Z_p
scoped_numeral p(nm);
nm.set(p, 2);
zp_manager zp_upm(nm.m());
zp_manager zp_upm(upm.lim(), nm.m());
zp_upm.set_zp(p);
zp_factors zp_fs(zp_upm);
scoped_numeral zp_fs_p(nm); nm.set(zp_fs_p, 2);
@ -1163,7 +1163,7 @@ bool factor_square_free(z_manager & upm, numeral_vector const & f, factors & fs,
);
// we got a prime factoring, so we do the lifting now
zp_manager zpe_upm(nm.m());
zp_manager zpe_upm(upm.lim(), nm.m());
zpe_upm.set_zp(zp_fs_p);
zp_numeral_manager & zpe_nm = zpe_upm.m();

View file

@ -369,6 +369,7 @@ namespace realclosure {
typedef sbuffer<int, REALCLOSURE_INI_BUFFER_SIZE> int_buffer;
typedef sbuffer<unsigned, REALCLOSURE_INI_BUFFER_SIZE> unsigned_buffer;
reslimit& m_limit;
small_object_allocator * m_allocator;
bool m_own_allocator;
unsynch_mpq_manager & m_qm;
@ -400,7 +401,6 @@ namespace realclosure {
bool m_in_aux_values; // True if we are computing SquareFree polynomials or Sturm sequences. That is, the values being computed will be discarded.
volatile bool m_cancel;
struct scoped_polynomial_seq {
typedef ref_buffer<value, imp, REALCLOSURE_INI_SEQ_SIZE> value_seq;
@ -494,14 +494,15 @@ namespace realclosure {
#define INC_DEPTH() ((void) 0)
#endif
imp(unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a):
imp(reslimit& lim, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a):
m_limit(lim),
m_allocator(a == 0 ? alloc(small_object_allocator, "realclosure") : a),
m_own_allocator(a == 0),
m_qm(qm),
m_mm(m_qm, *m_allocator),
m_bqm(m_qm),
m_qim(m_qm),
m_bqim(m_bqm),
m_qim(lim, m_qm),
m_bqim(lim, m_bqm),
m_plus_inf_approx(m_bqm),
m_minus_inf_approx(m_bqm) {
mpq one(1);
@ -514,7 +515,6 @@ namespace realclosure {
m_in_aux_values = false;
m_cancel = false;
updt_params(p);
}
@ -547,7 +547,7 @@ namespace realclosure {
small_object_allocator & allocator() { return *m_allocator; }
void checkpoint() {
if (m_cancel)
if (!m_limit.inc())
throw exception("canceled");
cooperate("rcf");
}
@ -730,9 +730,6 @@ namespace realclosure {
return m_extensions[extension::ALGEBRAIC].size();
}
void set_cancel(bool f) {
m_cancel = f;
}
void updt_params(params_ref const & _p) {
rcf_params p(_p);
@ -6033,8 +6030,8 @@ namespace realclosure {
~save_interval_ctx() { m->restore_saved_intervals(); }
};
manager::manager(unsynch_mpq_manager & m, params_ref const & p, small_object_allocator * a) {
m_imp = alloc(imp, m, p, a);
manager::manager(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p, small_object_allocator * a) {
m_imp = alloc(imp, lim, m, p, a);
}
manager::~manager() {
@ -6045,10 +6042,6 @@ namespace realclosure {
rcf_params::collect_param_descrs(r);
}
void manager::set_cancel(bool f) {
m_imp->set_cancel(f);
}
void manager::updt_params(params_ref const & p) {
m_imp->updt_params(p);
}

View file

@ -28,6 +28,7 @@ Notes:
#include"scoped_numeral_vector.h"
#include"interval.h"
#include"z3_exception.h"
#include"rlimit.h"
namespace realclosure {
class num;
@ -47,7 +48,7 @@ namespace realclosure {
friend class save_interval_ctx;
imp * m_imp;
public:
manager(unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
manager(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
~manager();
typedef num numeral;
typedef svector<numeral> numeral_vector;
@ -57,9 +58,6 @@ namespace realclosure {
static void get_param_descrs(param_descrs & r);
static void collect_param_descrs(param_descrs & r) { get_param_descrs(r); }
void set_cancel(bool f);
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
void updt_params(params_ref const & p);

View file

@ -92,11 +92,11 @@ namespace simplex {
};
static const var_t null_var;
reslimit& m_limit;
mutable manager m;
mutable eps_manager em;
mutable matrix M;
unsigned m_max_iterations;
volatile bool m_cancel;
var_heap m_to_patch;
vector<var_info> m_vars;
svector<var_t> m_row2base;
@ -109,10 +109,10 @@ namespace simplex {
stats m_stats;
public:
simplex():
simplex(reslimit& lim):
m_limit(lim),
M(m),
m_max_iterations(UINT_MAX),
m_cancel(false),
m_to_patch(1024),
m_bland(false),
m_blands_rule_threshold(1000) {}
@ -140,7 +140,6 @@ namespace simplex {
void unset_lower(var_t var);
void unset_upper(var_t var);
void set_value(var_t var, eps_numeral const& b);
void set_cancel(bool f) { m_cancel = f; }
void set_max_iterations(unsigned n) { m_max_iterations = n; }
void reset();
lbool make_feasible();

View file

@ -332,7 +332,7 @@ namespace simplex {
SASSERT(well_formed());
while ((v = select_var_to_fix()) != null_var) {
TRACE("simplex", display(tout << "v" << v << "\n"););
if (m_cancel || num_iterations > m_max_iterations) {
if (!m_limit.inc() || num_iterations > m_max_iterations) {
return l_undef;
}
check_blands_rule(v, num_repeated);
@ -670,7 +670,7 @@ namespace simplex {
bool inc_x_i, inc_x_j;
while (true) {
if (m_cancel) {
if (!m_limit.inc()) {
return l_undef;
}
select_pivot_primal(v, x_i, x_j, a_ij, inc_x_i, inc_x_j);

View file

@ -37,7 +37,7 @@ namespace subpaving {
protected:
CTX m_ctx;
public:
context_wrapper(typename CTX::numeral_manager & m, params_ref const & p, small_object_allocator * a):m_ctx(m, p, a) {}
context_wrapper(reslimit& lim, typename CTX::numeral_manager & m, params_ref const & p, small_object_allocator * a):m_ctx(lim, m, p, a) {}
virtual ~context_wrapper() {}
virtual unsigned num_vars() const { return m_ctx.num_vars(); }
virtual var mk_var(bool is_int) { return m_ctx.mk_var(is_int); }
@ -47,7 +47,6 @@ namespace subpaving {
virtual void dec_ref(ineq * a) { m_ctx.dec_ref(reinterpret_cast<typename CTX::ineq*>(a)); }
virtual void add_clause(unsigned sz, ineq * const * atoms) { m_ctx.add_clause(sz, reinterpret_cast<typename CTX::ineq * const *>(atoms)); }
virtual void display_constraints(std::ostream & out, bool use_star) const { m_ctx.display_constraints(out, use_star); }
virtual void set_cancel(bool f) { m_ctx.set_cancel(f); }
virtual void set_display_proc(display_var_proc * p) { m_ctx.set_display_proc(p); }
virtual void reset_statistics() { m_ctx.reset_statistics(); }
virtual void collect_statistics(statistics & st) const { m_ctx.collect_statistics(st); }
@ -61,8 +60,8 @@ namespace subpaving {
scoped_mpq m_c;
scoped_mpq_vector m_as;
public:
context_mpq_wrapper(unsynch_mpq_manager & m, params_ref const & p, small_object_allocator * a):
context_wrapper<context_mpq>(m, p, a),
context_mpq_wrapper(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p, small_object_allocator * a):
context_wrapper<context_mpq>(lim, m, p, a),
m_c(m),
m_as(m)
{}
@ -100,8 +99,8 @@ namespace subpaving {
}
public:
context_mpf_wrapper(f2n<mpf_manager> & fm, params_ref const & p, small_object_allocator * a):
context_wrapper<context_mpf>(fm, p, a),
context_mpf_wrapper(reslimit& lim, f2n<mpf_manager> & fm, params_ref const & p, small_object_allocator * a):
context_wrapper<context_mpf>(lim, fm, p, a),
m_qm(fm.m().mpq_manager()),
m_c(fm.m()),
m_as(fm.m()),
@ -161,8 +160,8 @@ namespace subpaving {
}
public:
context_hwf_wrapper(f2n<hwf_manager> & fm, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a):
context_wrapper<context_hwf>(fm, p, a),
context_hwf_wrapper(reslimit& lim,f2n<hwf_manager> & fm, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a):
context_wrapper<context_hwf>(lim, fm, p, a),
m_qm(qm) {
}
@ -215,8 +214,8 @@ namespace subpaving {
}
public:
context_fpoint_wrapper(typename context_fpoint::numeral_manager & m, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a):
context_wrapper<context_fpoint>(m, p, a),
context_fpoint_wrapper(reslimit& lim, typename context_fpoint::numeral_manager & m, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a):
context_wrapper<context_fpoint>(lim, m, p, a),
m_qm(qm),
m_c(m),
m_as(m),
@ -261,24 +260,24 @@ namespace subpaving {
typedef context_fpoint_wrapper<context_mpff> context_mpff_wrapper;
typedef context_fpoint_wrapper<context_mpfx> context_mpfx_wrapper;
context * mk_mpq_context(unsynch_mpq_manager & m, params_ref const & p, small_object_allocator * a) {
return alloc(context_mpq_wrapper, m, p, a);
context * mk_mpq_context(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p, small_object_allocator * a) {
return alloc(context_mpq_wrapper, lim, m, p, a);
}
context * mk_mpf_context(f2n<mpf_manager> & m, params_ref const & p, small_object_allocator * a) {
return alloc(context_mpf_wrapper, m, p, a);
context * mk_mpf_context(reslimit& lim, f2n<mpf_manager> & m, params_ref const & p, small_object_allocator * a) {
return alloc(context_mpf_wrapper, lim, m, p, a);
}
context * mk_hwf_context(f2n<hwf_manager> & m, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a) {
return alloc(context_hwf_wrapper, m, qm, p, a);
context * mk_hwf_context(reslimit& lim, f2n<hwf_manager> & m, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a) {
return alloc(context_hwf_wrapper, lim, m, qm, p, a);
}
context * mk_mpff_context(mpff_manager & m, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a) {
return alloc(context_mpff_wrapper, m, qm, p, a);
context * mk_mpff_context(reslimit& lim, mpff_manager & m, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a) {
return alloc(context_mpff_wrapper, lim, m, qm, p, a);
}
context * mk_mpfx_context(mpfx_manager & m, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a) {
return alloc(context_mpfx_wrapper, m, qm, p, a);
context * mk_mpfx_context(reslimit& lim, mpfx_manager & m, unsynch_mpq_manager & qm, params_ref const & p, small_object_allocator * a) {
return alloc(context_mpfx_wrapper, lim, m, qm, p, a);
}
};

View file

@ -95,7 +95,6 @@ public:
*/
virtual void display_constraints(std::ostream & out, bool use_star = false) const = 0;
virtual void set_cancel(bool f) = 0;
virtual void collect_param_descrs(param_descrs & r) = 0;
@ -112,11 +111,11 @@ public:
virtual void display_bounds(std::ostream & out) const = 0;
};
context * mk_mpq_context(unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
context * mk_mpf_context(f2n<mpf_manager> & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
context * mk_hwf_context(f2n<hwf_manager> & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0);
context * mk_mpff_context(mpff_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0);
context * mk_mpfx_context(mpfx_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0);
context * mk_mpq_context(reslimit& lim, unsynch_mpq_manager & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
context * mk_mpf_context(reslimit& lim, f2n<mpf_manager> & m, params_ref const & p = params_ref(), small_object_allocator * a = 0);
context * mk_hwf_context(reslimit& lim, f2n<hwf_manager> & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0);
context * mk_mpff_context(reslimit& lim, mpff_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0);
context * mk_mpfx_context(reslimit& lim, mpfx_manager & m, unsynch_mpq_manager & qm, params_ref const & p = params_ref(), small_object_allocator * a = 0);
};

View file

@ -40,7 +40,7 @@ public:
class context_hwf : public context_t<config_hwf> {
public:
context_hwf(f2n<hwf_manager> & m, params_ref const & p, small_object_allocator * a):context_t<config_hwf>(config_hwf(m), p, a) {}
context_hwf(reslimit& lim, f2n<hwf_manager> & m, params_ref const & p, small_object_allocator * a):context_t<config_hwf>(lim, config_hwf(m), p, a) {}
};
};

View file

@ -41,7 +41,7 @@ public:
class context_mpf : public context_t<config_mpf> {
public:
context_mpf(f2n<mpf_manager> & m, params_ref const & p, small_object_allocator * a):context_t<config_mpf>(config_mpf(m), p, a) {}
context_mpf(reslimit& lim, f2n<mpf_manager> & m, params_ref const & p, small_object_allocator * a):context_t<config_mpf>(lim, config_mpf(m), p, a) {}
};
};

View file

@ -31,6 +31,7 @@ Revision History:
#include"statistics.h"
#include"lbool.h"
#include"id_gen.h"
#include"rlimit.h"
#ifdef _MSC_VER
#pragma warning(disable : 4200)
#pragma warning(disable : 4355)
@ -466,6 +467,7 @@ public:
typedef _scoped_numeral_vector<numeral_manager> scoped_numeral_vector;
private:
reslimit& m_limit;
C m_c;
bool m_arith_failed; //!< True if the arithmetic module produced an exception.
bool m_own_allocator;
@ -526,8 +528,6 @@ private:
numeral m_tmp1, m_tmp2, m_tmp3;
interval m_i_tmp1, m_i_tmp2, m_i_tmp3;
// Cancel flag
volatile bool m_cancel;
friend class node;
@ -759,7 +759,7 @@ private:
bool check_invariant() const;
public:
context_t(C const & c, params_ref const & p, small_object_allocator * a);
context_t(reslimit& lim, C const & c, params_ref const & p, small_object_allocator * a);
~context_t();
/**
@ -835,8 +835,6 @@ public:
void set_display_proc(display_var_proc * p) { m_display_proc = p; }
void set_cancel(bool f) { m_cancel = f; im().set_cancel(f); }
void updt_params(params_ref const & p);
static void collect_param_descrs(param_descrs & d);

View file

@ -413,12 +413,13 @@ void context_t<C>::polynomial::display(std::ostream & out, numeral_manager & nm,
}
template<typename C>
context_t<C>::context_t(C const & c, params_ref const & p, small_object_allocator * a):
context_t<C>::context_t(reslimit& lim, C const & c, params_ref const & p, small_object_allocator * a):
m_limit(lim),
m_c(c),
m_own_allocator(a == 0),
m_allocator(a == 0 ? alloc(small_object_allocator, "subpaving") : a),
m_bm(*this, *m_allocator),
m_im(interval_config(m_c.m())),
m_im(lim, interval_config(m_c.m())),
m_num_buffer(nm()) {
m_arith_failed = false;
m_timestamp = 0;
@ -431,7 +432,6 @@ context_t<C>::context_t(C const & c, params_ref const & p, small_object_allocato
m_node_selector = alloc(breadth_first_node_selector<C>, this);
m_var_selector = alloc(round_robing_var_selector<C>, this);
m_node_splitter = alloc(midpoint_node_splitter<C>, this);
m_cancel = false;
m_num_nodes = 0;
updt_params(p);
reset_statistics();
@ -459,7 +459,7 @@ context_t<C>::~context_t() {
template<typename C>
void context_t<C>::checkpoint() {
if (m_cancel)
if (!m_limit.inc())
throw default_exception("canceled");
if (memory::get_allocation_size() > m_max_memory)
throw default_exception(Z3_MAX_MEMORY_MSG);

View file

@ -51,7 +51,6 @@ struct expr2subpaving::imp {
obj_map<expr, subpaving::ineq*> m_lit_cache;
volatile bool m_cancel;
imp(ast_manager & m, subpaving::context & s, expr2var * e2v):
m_manager(m),
@ -71,7 +70,6 @@ struct expr2subpaving::imp {
m_expr2var_owner = false;
}
m_cancel = false;
}
~imp() {
@ -95,7 +93,7 @@ struct expr2subpaving::imp {
}
void checkpoint() {
if (m_cancel)
if (m().canceled())
throw default_exception("canceled");
cooperate("expr2subpaving");
}
@ -357,9 +355,6 @@ struct expr2subpaving::imp {
return m_expr2var->is_var(t);
}
void set_cancel(bool f) {
m_cancel = f;
}
subpaving::var internalize_term(expr * t, mpz & n, mpz & d) {
return process(t, 0, n, d);
@ -386,9 +381,6 @@ bool expr2subpaving::is_var(expr * t) const {
return m_imp->is_var(t);
}
void expr2subpaving::set_cancel(bool f) {
m_imp->set_cancel(f);
}
subpaving::var expr2subpaving::internalize_term(expr * t, mpz & n, mpz & d) {
return m_imp->internalize_term(t, n, d);

View file

@ -41,11 +41,6 @@ public:
*/
bool is_var(expr * t) const;
/**
\brief Cancel/Interrupt execution.
*/
void set_cancel(bool f);
/**
\brief Internalize a Z3 arithmetical expression into the subpaving data-structure.

View file

@ -103,11 +103,11 @@ class subpaving_tactic : public tactic {
if (m_kind != new_kind) {
m_kind = new_kind;
switch (m_kind) {
case MPQ: m_ctx = subpaving::mk_mpq_context(m_qm); break;
case MPF: m_ctx = subpaving::mk_mpf_context(m_fm); break;
case HWF: m_ctx = subpaving::mk_hwf_context(m_hm, m_qm); break;
case MPFF: m_ctx = subpaving::mk_mpff_context(m_ffm, m_qm); break;
case MPFX: m_ctx = subpaving::mk_mpfx_context(m_fxm, m_qm); break;
case MPQ: m_ctx = subpaving::mk_mpq_context(m().limit(), m_qm); break;
case MPF: m_ctx = subpaving::mk_mpf_context(m().limit(), m_fm); break;
case HWF: m_ctx = subpaving::mk_hwf_context(m().limit(), m_hm, m_qm); break;
case MPFF: m_ctx = subpaving::mk_mpff_context(m().limit(), m_ffm, m_qm); break;
case MPFX: m_ctx = subpaving::mk_mpfx_context(m().limit(), m_fxm, m_qm); break;
default: UNREACHABLE(); break;
}
m_e2s = alloc(expr2subpaving, m_manager, *m_ctx, &m_e2v);
@ -123,11 +123,6 @@ class subpaving_tactic : public tactic {
m_ctx->reset_statistics();
}
void set_cancel(bool f) {
m_e2s->set_cancel(f);
m_ctx->set_cancel(f);
}
subpaving::ineq * mk_ineq(expr * a) {
bool neg = false;
while (m().is_not(a, a))
@ -266,24 +261,10 @@ public:
virtual void cleanup() {
ast_manager & m = m_imp->m();
imp * d = m_imp;
#pragma omp critical (tactic_cancel)
{
d = m_imp;
}
dealloc(d);
d = alloc(imp, m, m_params);
#pragma omp critical (tactic_cancel)
{
m_imp = d;
}
dealloc(m_imp);
m_imp = alloc(imp, m, m_params);
}
protected:
virtual void set_cancel(bool f) {
if (m_imp)
m_imp->set_cancel(f);
}
};

View file

@ -256,12 +256,6 @@ unsigned model_evaluator::get_num_steps() const {
return m_imp->get_num_steps();
}
void model_evaluator::set_cancel(bool f) {
#pragma omp critical (model_evaluator)
{
m_imp->set_cancel(f);
}
}
void model_evaluator::cleanup(params_ref const & p) {
model & md = m_imp->cfg().m_model;

View file

@ -41,9 +41,6 @@ public:
void operator()(expr * t, expr_ref & r);
void set_cancel(bool f);
void cancel() { set_cancel(true); }
void reset_cancel() { set_cancel(false); }
void cleanup(params_ref const & p = params_ref());
void reset(params_ref const & p = params_ref());

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);
}
@ -750,16 +749,7 @@ namespace datalog {
m_background.push_back(e);
}
void context::cancel() {
m_cancel = true;
m_last_status = CANCELED;
m_transf.cancel();
if (m_engine) m_engine->cancel();
}
void context::cleanup() {
m_cancel = false;
m_last_status = OK;
if (m_engine) m_engine->cleanup();
}

View file

@ -209,7 +209,6 @@ namespace datalog {
execution_result m_last_status;
expr_ref m_last_answer;
DL_ENGINE m_engine_type;
volatile bool m_cancel;
@ -487,11 +486,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.canceled();
}
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

@ -483,7 +483,7 @@ namespace datalog {
}
proof_ref get_proof(model_ref& md, func_decl* pred, app* prop, unsigned level) {
if (b.m_cancel) {
if (m.canceled()) {
return proof_ref(0, m);
}
TRACE("bmc", tout << "Predicate: " << pred->get_name() << "\n";);
@ -1172,7 +1172,7 @@ namespace datalog {
private:
void get_model(unsigned level) {
if (b.m_cancel) {
if (m.canceled()) {
return;
}
rule_manager& rm = b.m_ctx.get_rule_manager();
@ -1426,8 +1426,7 @@ namespace datalog {
m_solver(m, m_fparams),
m_rules(ctx),
m_query_pred(m),
m_answer(m),
m_cancel(false) {
m_answer(m) {
}
bmc::~bmc() {}
@ -1510,21 +1509,11 @@ namespace datalog {
}
void bmc::checkpoint() {
if (m_cancel) {
if (m.canceled()) {
throw default_exception("bmc canceled");
}
}
void bmc::cancel() {
m_cancel = true;
m_solver.cancel();
}
void bmc::cleanup() {
m_cancel = false;
m_solver.reset();
}
void bmc::display_certificate(std::ostream& out) const {
out << mk_pp(m_answer, m) << "\n";
}

View file

@ -38,7 +38,6 @@ namespace datalog {
rule_set m_rules;
func_decl_ref m_query_pred;
expr_ref m_answer;
volatile bool m_cancel;
void checkpoint();
@ -59,10 +58,6 @@ namespace datalog {
lbool query(expr* query);
void cancel();
void cleanup();
void display_certificate(std::ostream& out) const;
void collect_statistics(statistics& st) const;

View file

@ -44,7 +44,6 @@ namespace datalog {
var_subst m_var_subst;
expr_ref_vector m_ground;
app_ref_vector m_goals;
volatile bool m_cancel;
stats m_stats;
public:
imp(context& ctx):
@ -54,8 +53,7 @@ namespace datalog {
m_solver(m, m_fparams), // TBD: can be replaced by efficient BV solver.
m_var_subst(m, false),
m_ground(m),
m_goals(m),
m_cancel(false)
m_goals(m)
{
// m_fparams.m_relevancy_lvl = 0;
m_fparams.m_mbqi = false;
@ -85,16 +83,6 @@ namespace datalog {
return search(20, 0);
}
void cancel() {
m_cancel = true;
m_solver.cancel();
}
void cleanup() {
m_cancel = false;
m_goals.reset();
m_solver.reset_cancel();
}
void reset_statistics() {
m_stats.reset();
@ -223,12 +211,7 @@ namespace datalog {
lbool clp::query(expr* query) {
return m_imp->query(query);
}
void clp::cancel() {
m_imp->cancel();
}
void clp::cleanup() {
m_imp->cleanup();
}
void clp::reset_statistics() {
m_imp->reset_statistics();
}

View file

@ -34,8 +34,6 @@ namespace datalog {
clp(context& ctx);
~clp();
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

@ -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,14 +516,6 @@ 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

@ -63,12 +63,6 @@ class horn_tactic : public tactic {
m_ctx.collect_statistics(st);
}
void set_cancel(bool f) {
if (f) {
m_ctx.cancel();
}
}
void normalize(expr_ref& f) {
bool is_positive = true;
expr* e = 0;
@ -409,25 +403,13 @@ public:
virtual void cleanup() {
ast_manager & m = m_imp->m;
imp * d = m_imp;
d->collect_statistics(m_stats);
#pragma omp critical (tactic_cancel)
{
m_imp = 0;
}
dealloc(d);
d = alloc(imp, m_is_simplify, m, m_params);
#pragma omp critical (tactic_cancel)
{
m_imp = d;
}
m_imp->collect_statistics(m_stats);
dealloc(m_imp);
m_imp = alloc(imp, m_is_simplify, m, m_params);
}
protected:
virtual void set_cancel(bool f) {
if (m_imp)
m_imp->set_cancel(f);
}
};
tactic * mk_horn_tactic(ast_manager & m, params_ref const & p) {

View file

@ -1453,8 +1453,7 @@ namespace pdr {
m_search(m_params.pdr_bfs_model_search()),
m_last_result(l_undef),
m_inductive_lvl(0),
m_expanded_lvl(0),
m_cancel(false)
m_expanded_lvl(0)
{
}
@ -1465,7 +1464,6 @@ namespace pdr {
void context::reset() {
TRACE("pdr", tout << "\n";);
cleanup();
decl2rel::iterator it = m_rels.begin(), end = m_rels.end();
for (; it != end; ++it) {
dealloc(it->m_value);
@ -1912,16 +1910,8 @@ namespace pdr {
return l_undef;
}
void context::cancel() {
m_cancel = true;
}
void context::cleanup() {
m_cancel = false;
}
void context::checkpoint() {
if (m_cancel) {
if (m.canceled()) {
throw default_exception("pdr canceled");
}
}

View file

@ -336,7 +336,6 @@ namespace pdr {
unsigned m_expanded_lvl;
ptr_vector<core_generalizer> m_core_generalizers;
stats m_stats;
volatile bool m_cancel;
model_converter_ref m_mc;
proof_converter_ref m_pc;
@ -411,9 +410,6 @@ namespace pdr {
lbool solve();
void cancel();
void cleanup();
void reset();

View file

@ -206,13 +206,7 @@ expr_ref dl_interface::get_answer() {
return m_context->get_answer();
}
void dl_interface::cancel() {
m_context->cancel();
}
void dl_interface::cleanup() {
m_context->cleanup();
}
void dl_interface::updt_params() {
dealloc(m_context);

View file

@ -51,10 +51,6 @@ namespace pdr {
virtual lbool query(expr* query);
virtual void cancel();
virtual void cleanup();
virtual void display_certificate(std::ostream& out) const;
virtual void collect_statistics(statistics& st) const;

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

@ -498,10 +498,6 @@ namespace datalog {
return dynamic_cast<karr_relation const&>(r);
}
void karr_relation_plugin::set_cancel(bool f) {
m_hb.set_cancel(f);
}
relation_base * karr_relation_plugin::mk_empty(const relation_signature & s) {
return alloc(karr_relation, *this, 0, s, true);
}

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())
{}
@ -50,8 +51,6 @@ namespace datalog {
static symbol get_name() { return symbol("karr_relation"); }
virtual void set_cancel(bool f);
virtual relation_base * mk_empty(const relation_signature & s);
virtual relation_base * mk_full(func_decl* p, const relation_signature & s);

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.canceled() && 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.canceled() && 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.canceled() && 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.canceled()) {
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;
@ -1394,17 +1379,8 @@ namespace datalog {
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.canceled()) {
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;

Some files were not shown because too many files have changed in this diff Show more