3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-06 17:44:08 +00:00

some more rewrites

This commit is contained in:
Nikolaj Bjorner 2020-07-30 10:19:32 -07:00
parent 59d8895d15
commit a74ef394ec
2 changed files with 23 additions and 2 deletions

View file

@ -824,7 +824,6 @@ br_status seq_rewriter::mk_seq_length(expr* a, expr_ref& result) {
result = m_autil.mk_add(es.size(), es.c_ptr());
return BR_REWRITE2;
}
#if 0
expr* s = nullptr, *offset = nullptr, *length = nullptr;
if (str().is_extract(a, s, offset, length)) {
expr_ref len_s(str().mk_length(s), m());
@ -843,7 +842,6 @@ br_status seq_rewriter::mk_seq_length(expr* a, expr_ref& result) {
result);
return BR_REWRITE_FULL;
}
#endif
return BR_FAILED;
}
@ -3811,6 +3809,9 @@ br_status seq_rewriter::mk_eq_core(expr * l, expr * r, expr_ref & result) {
return reduce_re_eq(l, r, result);
}
bool changed = false;
if (reduce_eq_empty(l, r, result))
return BR_REWRITE3;
if (!reduce_eq(l, r, new_eqs, changed)) {
result = m().mk_false();
TRACE("seq_verbose", tout << result << "\n";);
@ -4207,6 +4208,25 @@ bool seq_rewriter::reduce_itos(expr_ref_vector& ls, expr_ref_vector& rs,
return true;
}
bool seq_rewriter::reduce_eq_empty(expr* l, expr* r, expr_ref& result) {
if (str().is_empty(r))
std::swap(l,r);
if (!str().is_empty(l))
return false;
expr* s = nullptr, *offset = nullptr, *len = nullptr;
if (str().is_extract(r, s, offset, len)) {
expr_ref len_s(str().mk_length(s), m());
expr_ref_vector fmls(m());
fmls.push_back(m_autil.mk_lt(offset, m_autil.mk_int(0)));
fmls.push_back(m().mk_eq(s, l));
fmls.push_back(m_autil.mk_lt(len, m_autil.mk_int(0)));
fmls.push_back(m_autil.mk_ge(offset, len_s));
result = m().mk_or(fmls);
return true;
}
return false;
}
bool seq_rewriter::reduce_by_length(expr_ref_vector& ls, expr_ref_vector& rs,
expr_ref_pair_vector& eqs) {

View file

@ -268,6 +268,7 @@ class seq_rewriter {
bool reduce_subsequence(expr_ref_vector& ls, expr_ref_vector& rs, expr_ref_pair_vector& eqs);
bool reduce_by_length(expr_ref_vector& ls, expr_ref_vector& rs, expr_ref_pair_vector& eqs);
bool reduce_itos(expr_ref_vector& ls, expr_ref_vector& rs, expr_ref_pair_vector& eqs);
bool reduce_eq_empty(expr* l, expr* r, expr_ref& result);
bool min_length(expr_ref_vector const& es, unsigned& len);
expr* concat_non_empty(expr_ref_vector& es);