mirror of
https://github.com/Z3Prover/z3
synced 2025-08-13 14:40:55 +00:00
address inconsistent states encountered when cancelling, #1197
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
19bb55e396
commit
00742566fb
4 changed files with 99 additions and 97 deletions
|
@ -128,6 +128,10 @@ namespace smt {
|
||||||
return literal(v, lit.sign());
|
return literal(v, lit.sign());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool context::get_cancel_flag() {
|
||||||
|
return !m_manager.limit().inc();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void context::copy(context& src_ctx, context& dst_ctx) {
|
void context::copy(context& src_ctx, context& dst_ctx) {
|
||||||
ast_manager& dst_m = dst_ctx.get_manager();
|
ast_manager& dst_m = dst_ctx.get_manager();
|
||||||
|
@ -235,10 +239,8 @@ namespace smt {
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy theory plugins
|
// copy theory plugins
|
||||||
ptr_vector<theory>::iterator it2 = src.m_theory_set.begin();
|
for (theory* old_th : src.m_theory_set) {
|
||||||
ptr_vector<theory>::iterator end2 = src.m_theory_set.end();
|
theory * new_th = old_th->mk_fresh(&dst);
|
||||||
for (; it2 != end2; ++it2) {
|
|
||||||
theory * new_th = (*it2)->mk_fresh(&dst);
|
|
||||||
dst.register_plugin(new_th);
|
dst.register_plugin(new_th);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -250,8 +252,6 @@ namespace smt {
|
||||||
return new_ctx;
|
return new_ctx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void context::init() {
|
void context::init() {
|
||||||
app * t = m_manager.mk_true();
|
app * t = m_manager.mk_true();
|
||||||
mk_bool_var(t);
|
mk_bool_var(t);
|
||||||
|
@ -2403,6 +2403,7 @@ namespace smt {
|
||||||
*/
|
*/
|
||||||
unsigned context::pop_scope_core(unsigned num_scopes) {
|
unsigned context::pop_scope_core(unsigned num_scopes) {
|
||||||
|
|
||||||
|
try {
|
||||||
if (m_manager.has_trace_stream())
|
if (m_manager.has_trace_stream())
|
||||||
m_manager.trace_stream() << "[pop] " << num_scopes << " " << m_scope_lvl << "\n";
|
m_manager.trace_stream() << "[pop] " << num_scopes << " " << m_scope_lvl << "\n";
|
||||||
|
|
||||||
|
@ -2447,10 +2448,8 @@ namespace smt {
|
||||||
unassign_vars(s.m_assigned_literals_lim);
|
unassign_vars(s.m_assigned_literals_lim);
|
||||||
undo_trail_stack(s.m_trail_stack_lim);
|
undo_trail_stack(s.m_trail_stack_lim);
|
||||||
|
|
||||||
ptr_vector<theory>::iterator it = m_theory_set.begin();
|
for (theory* th : m_theory_set) {
|
||||||
ptr_vector<theory>::iterator end = m_theory_set.end();
|
th->pop_scope_eh(num_scopes);
|
||||||
for (; it != end; ++it) {
|
|
||||||
(*it)->pop_scope_eh(num_scopes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
del_justifications(m_justifications, s.m_justifications_lim);
|
del_justifications(m_justifications, s.m_justifications_lim);
|
||||||
|
@ -2479,6 +2478,12 @@ namespace smt {
|
||||||
CASSERT("context", check_invariant());
|
CASSERT("context", check_invariant());
|
||||||
return num_bool_vars;
|
return num_bool_vars;
|
||||||
}
|
}
|
||||||
|
catch (...) {
|
||||||
|
// throwing inside pop is just not cool.
|
||||||
|
UNREACHABLE();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void context::pop_scope(unsigned num_scopes) {
|
void context::pop_scope(unsigned num_scopes) {
|
||||||
pop_scope_core(num_scopes);
|
pop_scope_core(num_scopes);
|
||||||
|
@ -3418,10 +3423,9 @@ namespace smt {
|
||||||
}
|
}
|
||||||
|
|
||||||
void context::init_search() {
|
void context::init_search() {
|
||||||
ptr_vector<theory>::iterator it = m_theory_set.begin();
|
for (theory* th : m_theory_set) {
|
||||||
ptr_vector<theory>::iterator end = m_theory_set.end();
|
th->init_search_eh();
|
||||||
for (; it != end; ++it)
|
}
|
||||||
(*it)->init_search_eh();
|
|
||||||
m_qmanager->init_search_eh();
|
m_qmanager->init_search_eh();
|
||||||
m_assumption_core.reset();
|
m_assumption_core.reset();
|
||||||
m_incomplete_theories.reset();
|
m_incomplete_theories.reset();
|
||||||
|
|
|
@ -257,15 +257,7 @@ namespace smt {
|
||||||
return m_params;
|
return m_params;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get_cancel_flag() {
|
bool get_cancel_flag();
|
||||||
if (m_manager.limit().inc()) {
|
|
||||||
// get_simplifier().reset();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
region & get_region() {
|
region & get_region() {
|
||||||
return m_region;
|
return m_region;
|
||||||
|
|
|
@ -2106,6 +2106,7 @@ namespace smt {
|
||||||
|
|
||||||
template<typename Ext>
|
template<typename Ext>
|
||||||
void theory_arith<Ext>::mutate_assignment() {
|
void theory_arith<Ext>::mutate_assignment() {
|
||||||
|
SASSERT(m_to_patch.empty());
|
||||||
remove_fixed_vars_from_base();
|
remove_fixed_vars_from_base();
|
||||||
int num_vars = get_num_vars();
|
int num_vars = get_num_vars();
|
||||||
m_var_value_table.reset();
|
m_var_value_table.reset();
|
||||||
|
@ -2131,12 +2132,9 @@ namespace smt {
|
||||||
}
|
}
|
||||||
if (candidates.empty())
|
if (candidates.empty())
|
||||||
return;
|
return;
|
||||||
typename sbuffer<theory_var>::iterator it = candidates.begin();
|
|
||||||
typename sbuffer<theory_var>::iterator end = candidates.end();
|
|
||||||
m_tmp_var_set.reset();
|
m_tmp_var_set.reset();
|
||||||
m_tmp_var_set2.reset();
|
m_tmp_var_set2.reset();
|
||||||
for (; it != end; ++it) {
|
for (theory_var v : candidates) {
|
||||||
theory_var v = *it;
|
|
||||||
SASSERT(!is_fixed(v));
|
SASSERT(!is_fixed(v));
|
||||||
if (is_base(v)) {
|
if (is_base(v)) {
|
||||||
row & r = m_rows[get_var_row(v)];
|
row & r = m_rows[get_var_row(v)];
|
||||||
|
|
|
@ -449,6 +449,7 @@ namespace smt {
|
||||||
proof_ref pr(m);
|
proof_ref pr(m);
|
||||||
|
|
||||||
s(ante, s_ante, pr);
|
s(ante, s_ante, pr);
|
||||||
|
if (ctx.get_cancel_flag()) return;
|
||||||
negated = m.is_not(s_ante, s_ante_n);
|
negated = m.is_not(s_ante, s_ante_n);
|
||||||
if (negated) s_ante = s_ante_n;
|
if (negated) s_ante = s_ante_n;
|
||||||
ctx.internalize(s_ante, false);
|
ctx.internalize(s_ante, false);
|
||||||
|
@ -456,6 +457,7 @@ namespace smt {
|
||||||
if (negated) l_ante.neg();
|
if (negated) l_ante.neg();
|
||||||
|
|
||||||
s(conseq, s_conseq, pr);
|
s(conseq, s_conseq, pr);
|
||||||
|
if (ctx.get_cancel_flag()) return;
|
||||||
negated = m.is_not(s_conseq, s_conseq_n);
|
negated = m.is_not(s_conseq, s_conseq_n);
|
||||||
if (negated) s_conseq = s_conseq_n;
|
if (negated) s_conseq = s_conseq_n;
|
||||||
ctx.internalize(s_conseq, false);
|
ctx.internalize(s_conseq, false);
|
||||||
|
@ -1413,6 +1415,12 @@ namespace smt {
|
||||||
final_check_status result = FC_DONE;
|
final_check_status result = FC_DONE;
|
||||||
final_check_status ok;
|
final_check_status ok;
|
||||||
do {
|
do {
|
||||||
|
if (get_context().get_cancel_flag()) {
|
||||||
|
return FC_GIVEUP;
|
||||||
|
}
|
||||||
|
|
||||||
|
SASSERT(m_to_patch.empty());
|
||||||
|
|
||||||
TRACE("arith", tout << "m_final_check_idx: " << m_final_check_idx << ", result: " << result << "\n";);
|
TRACE("arith", tout << "m_final_check_idx: " << m_final_check_idx << ", result: " << result << "\n";);
|
||||||
switch (m_final_check_idx) {
|
switch (m_final_check_idx) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue