3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 13:28:47 +00:00
This commit is contained in:
Nikolaj Bjorner 2021-12-16 09:35:54 -08:00
parent 2caa7e6e45
commit dd6a11b526
2 changed files with 24 additions and 14 deletions

View file

@ -349,7 +349,7 @@ final_check_status theory_seq::final_check_eh() {
TRACEFIN("propagate_contains"); TRACEFIN("propagate_contains");
return FC_CONTINUE; return FC_CONTINUE;
} }
if (fixed_length(true)) { if (check_fixed_length(true, false)) {
++m_stats.m_fixed_length; ++m_stats.m_fixed_length;
TRACEFIN("zero_length"); TRACEFIN("zero_length");
return FC_CONTINUE; return FC_CONTINUE;
@ -359,7 +359,7 @@ final_check_status theory_seq::final_check_eh() {
TRACEFIN("split_based_on_length"); TRACEFIN("split_based_on_length");
return FC_CONTINUE; return FC_CONTINUE;
} }
if (fixed_length()) { if (check_fixed_length(false, false)) {
++m_stats.m_fixed_length; ++m_stats.m_fixed_length;
TRACEFIN("fixed_length"); TRACEFIN("fixed_length");
return FC_CONTINUE; return FC_CONTINUE;
@ -413,6 +413,11 @@ final_check_status theory_seq::final_check_eh() {
TRACEFIN("branch_itos"); TRACEFIN("branch_itos");
return FC_CONTINUE; return FC_CONTINUE;
} }
if (check_fixed_length(false, true)) {
++m_stats.m_fixed_length;
TRACEFIN("fixed_length");
return FC_CONTINUE;
}
if (m_unhandled_expr) { if (m_unhandled_expr) {
TRACEFIN("give_up"); TRACEFIN("give_up");
TRACE("seq", tout << "unhandled: " << mk_pp(m_unhandled_expr, m) << "\n";); TRACE("seq", tout << "unhandled: " << mk_pp(m_unhandled_expr, m) << "\n";);
@ -461,18 +466,18 @@ bool theory_seq::enforce_length(expr_ref_vector const& es, vector<rational> & le
} }
bool theory_seq::fixed_length(bool is_zero) { bool theory_seq::check_fixed_length(bool is_zero, bool check_long_strings) {
bool found = false; bool found = false;
for (unsigned i = 0; i < m_length.size(); ++i) { for (unsigned i = 0; i < m_length.size(); ++i) {
expr* e = m_length.get(i); expr* e = m_length.get(i);
if (fixed_length(e, is_zero)) { if (fixed_length(e, is_zero, check_long_strings)) {
found = true; found = true;
} }
} }
return found; return found;
} }
bool theory_seq::fixed_length(expr* len_e, bool is_zero) { bool theory_seq::fixed_length(expr* len_e, bool is_zero, bool check_long_strings) {
rational lo, hi; rational lo, hi;
expr* e = nullptr; expr* e = nullptr;
VERIFY(m_util.str.is_length(len_e, e)); VERIFY(m_util.str.is_length(len_e, e));
@ -493,6 +498,15 @@ bool theory_seq::fixed_length(expr* len_e, bool is_zero) {
expr_ref seq(e, m), head(m), tail(m); expr_ref seq(e, m), head(m), tail(m);
TRACE("seq", tout << "Fixed: " << mk_bounded_pp(e, m, 2) << " " << lo << "\n";);
literal a = mk_eq(len_e, m_autil.mk_numeral(lo, true), false);
if (ctx.get_assignment(a) == l_false)
return false;
if (!check_long_strings && lo > 20 && !is_zero)
return false;
if (lo.is_zero()) { if (lo.is_zero()) {
seq = m_util.str.mk_empty(e->get_sort()); seq = m_util.str.mk_empty(e->get_sort());
} }
@ -506,10 +520,6 @@ bool theory_seq::fixed_length(expr* len_e, bool is_zero) {
} }
seq = mk_concat(elems.size(), elems.data()); seq = mk_concat(elems.size(), elems.data());
} }
TRACE("seq", tout << "Fixed: " << mk_bounded_pp(e, m, 2) << " " << lo << "\n";);
literal a = mk_eq(len_e, m_autil.mk_numeral(lo, true), false);
if (ctx.get_assignment(a) == l_false)
return false;
literal b = mk_seq_eq(seq, e); literal b = mk_seq_eq(seq, e);
if (ctx.get_assignment(b) == l_true) if (ctx.get_assignment(b) == l_true)
return false; return false;

View file

@ -243,7 +243,7 @@ namespace smt {
replay_fixed_length(ast_manager& m, expr* e) : m_e(e, m) {} replay_fixed_length(ast_manager& m, expr* e) : m_e(e, m) {}
~replay_fixed_length() override {} ~replay_fixed_length() override {}
void operator()(theory_seq& th) override { void operator()(theory_seq& th) override {
th.fixed_length(m_e); th.fixed_length(m_e, false, false);
m_e.reset(); m_e.reset();
} }
}; };
@ -436,8 +436,8 @@ namespace smt {
bool check_length_coherence(); bool check_length_coherence();
bool check_length_coherence0(expr* e); bool check_length_coherence0(expr* e);
bool check_length_coherence(expr* e); bool check_length_coherence(expr* e);
bool fixed_length(bool is_zero = false); bool check_fixed_length(bool is_zero, bool check_long_strings);
bool fixed_length(expr* e, bool is_zero); bool fixed_length(expr* e, bool is_zero, bool check_long_strings);
bool branch_variable_eq(depeq const& e); bool branch_variable_eq(depeq const& e);
bool branch_binary_variable(depeq const& e); bool branch_binary_variable(depeq const& e);
bool can_align_from_lhs(expr_ref_vector const& ls, expr_ref_vector const& rs); bool can_align_from_lhs(expr_ref_vector const& ls, expr_ref_vector const& rs);