Skip to content

Commit

Permalink
fix #5715
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolajBjorner committed Dec 16, 2021
1 parent 2caa7e6 commit dd6a11b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
32 changes: 21 additions & 11 deletions src/smt/theory_seq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ final_check_status theory_seq::final_check_eh() {
TRACEFIN("propagate_contains");
return FC_CONTINUE;
}
if (fixed_length(true)) {
if (check_fixed_length(true, false)) {
++m_stats.m_fixed_length;
TRACEFIN("zero_length");
return FC_CONTINUE;
Expand All @@ -359,7 +359,7 @@ final_check_status theory_seq::final_check_eh() {
TRACEFIN("split_based_on_length");
return FC_CONTINUE;
}
if (fixed_length()) {
if (check_fixed_length(false, false)) {
++m_stats.m_fixed_length;
TRACEFIN("fixed_length");
return FC_CONTINUE;
Expand Down Expand Up @@ -413,6 +413,11 @@ final_check_status theory_seq::final_check_eh() {
TRACEFIN("branch_itos");
return FC_CONTINUE;
}
if (check_fixed_length(false, true)) {
++m_stats.m_fixed_length;
TRACEFIN("fixed_length");
return FC_CONTINUE;
}
if (m_unhandled_expr) {
TRACEFIN("give_up");
TRACE("seq", tout << "unhandled: " << mk_pp(m_unhandled_expr, m) << "\n";);
Expand Down Expand Up @@ -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;
for (unsigned i = 0; i < m_length.size(); ++i) {
expr* e = m_length.get(i);
if (fixed_length(e, is_zero)) {
if (fixed_length(e, is_zero, check_long_strings)) {
found = true;
}
}
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;
expr* e = nullptr;
VERIFY(m_util.str.is_length(len_e, e));
Expand All @@ -493,23 +498,28 @@ bool theory_seq::fixed_length(expr* len_e, bool is_zero) {

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()) {
seq = m_util.str.mk_empty(e->get_sort());
}
else if (!is_zero) {
unsigned _lo = lo.get_unsigned();
expr_ref_vector elems(m);
expr_ref_vector elems(m);
for (unsigned j = 0; j < _lo; ++j) {
m_sk.decompose(seq, head, tail);
elems.push_back(head);
seq = tail;
}
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);
if (ctx.get_assignment(b) == l_true)
return false;
Expand Down Expand Up @@ -2873,7 +2883,7 @@ void theory_seq::add_axiom(literal_vector & lits) {
for (literal lit : lits)
ctx.mark_as_relevant(lit);

IF_VERBOSE(10, verbose_stream() << "ax ";
IF_VERBOSE(10, verbose_stream() << "ax";
for (literal l : lits) ctx.display_literal_smt2(verbose_stream() << " ", l);
verbose_stream() << "\n");
m_new_propagation = true;
Expand Down
6 changes: 3 additions & 3 deletions src/smt/theory_seq.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ namespace smt {
replay_fixed_length(ast_manager& m, expr* e) : m_e(e, m) {}
~replay_fixed_length() override {}
void operator()(theory_seq& th) override {
th.fixed_length(m_e);
th.fixed_length(m_e, false, false);
m_e.reset();
}
};
Expand Down Expand Up @@ -436,8 +436,8 @@ namespace smt {
bool check_length_coherence();
bool check_length_coherence0(expr* e);
bool check_length_coherence(expr* e);
bool fixed_length(bool is_zero = false);
bool fixed_length(expr* e, bool is_zero);
bool check_fixed_length(bool is_zero, bool check_long_strings);
bool fixed_length(expr* e, bool is_zero, bool check_long_strings);
bool branch_variable_eq(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);
Expand Down

0 comments on commit dd6a11b

Please sign in to comment.