3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 09:05:31 +00:00

add equality propagation based on partial length information to sequence theory. Fix issue #429

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2016-02-04 08:12:46 -08:00
parent 9b979b6e1e
commit 9c7e5c37d1
8 changed files with 200 additions and 44 deletions

View file

@ -1484,6 +1484,7 @@ bool seq_rewriter::length_constrained(unsigned szl, expr* const* l, unsigned szr
if (is_sat) {
lhs.push_back(concat_non_empty(szl, l));
rhs.push_back(concat_non_empty(szr, r));
//split_units(lhs, rhs);
}
return true;
}
@ -1492,13 +1493,39 @@ bool seq_rewriter::length_constrained(unsigned szl, expr* const* l, unsigned szr
if (is_sat) {
lhs.push_back(concat_non_empty(szl, l));
rhs.push_back(concat_non_empty(szr, r));
//split_units(lhs, rhs);
}
return true;
}
}
return false;
}
void seq_rewriter::split_units(expr_ref_vector& lhs, expr_ref_vector& rhs) {
expr* a, *b, *a1, *b1, *a2, *b2;
while (true) {
if (m_util.str.is_unit(lhs.back(), a) &&
m_util.str.is_unit(rhs.back(), b)) {
lhs[lhs.size()-1] = a;
rhs[rhs.size()-1] = b;
break;
}
if (m_util.str.is_concat(lhs.back(), a, a2) &&
m_util.str.is_unit(a, a1) &&
m_util.str.is_concat(rhs.back(), b, b2) &&
m_util.str.is_unit(b, b1)) {
expr_ref _pin_a(lhs.back(), m()), _pin_b(rhs.back(), m());
lhs[lhs.size()-1] = a1;
rhs[rhs.size()-1] = b1;
lhs.push_back(a2);
rhs.push_back(b2);
}
else {
break;
}
}
}
bool seq_rewriter::is_epsilon(expr* e) const {
expr* e1;
return m_util.re.is_to_re(e, e1) && m_util.str.is_empty(e1);

View file

@ -113,6 +113,7 @@ class seq_rewriter {
bool is_sequence(expr* e, expr_ref_vector& seq);
bool is_sequence(eautomaton& aut, expr_ref_vector& seq);
bool is_epsilon(expr* e) const;
void split_units(expr_ref_vector& lhs, expr_ref_vector& rhs);
public:
seq_rewriter(ast_manager & m, params_ref const & p = params_ref()):