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

add length coherence check for length = 0

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2016-03-25 17:17:34 -07:00
parent f34a54fea0
commit 0870b4a5a0
2 changed files with 16 additions and 10 deletions

View file

@ -785,7 +785,6 @@ bool seq_decl_plugin::is_value(app* e) const {
e = to_app(e->get_arg(1)); e = to_app(e->get_arg(1));
continue; continue;
} }
TRACE("seq", tout << mk_pp(e, *m_manager) << "\n";);
return false; return false;
} }
} }

View file

@ -600,7 +600,7 @@ bool theory_seq::fixed_length() {
bool theory_seq::fixed_length(expr* e) { bool theory_seq::fixed_length(expr* e) {
rational lo, hi; rational lo, hi;
if (!(is_var(e) && lower_bound(e, lo) && upper_bound(e, hi) && lo == hi && lo.is_unsigned() && lo.is_pos())) { if (!(is_var(e) && lower_bound(e, lo) && upper_bound(e, hi) && lo == hi && lo.is_unsigned())) {
return false; return false;
} }
if (is_skolem(m_tail, e) || is_skolem(m_seq_first, e) || if (is_skolem(m_tail, e) || is_skolem(m_seq_first, e) ||
@ -609,13 +609,19 @@ bool theory_seq::fixed_length(expr* e) {
return false; return false;
} }
context& ctx = get_context(); context& ctx = get_context();
m_trail_stack.push(insert_obj_trail<theory_seq, expr>(m_fixed, e)); m_trail_stack.push(insert_obj_trail<theory_seq, expr>(m_fixed, e));
m_fixed.insert(e); m_fixed.insert(e);
unsigned _lo = lo.get_unsigned();
expr_ref seq(e, m), head(m), tail(m); expr_ref seq(e, m), head(m), tail(m);
if (lo.is_zero()) {
seq = m_util.str.mk_empty(m.get_sort(e));
}
else {
unsigned _lo = lo.get_unsigned();
expr_ref_vector elems(m); expr_ref_vector elems(m);
for (unsigned j = 0; j < _lo; ++j) { for (unsigned j = 0; j < _lo; ++j) {
@ -624,6 +630,7 @@ bool theory_seq::fixed_length(expr* e) {
seq = tail; seq = tail;
} }
seq = mk_concat(elems.size(), elems.c_ptr()); seq = mk_concat(elems.size(), elems.c_ptr());
}
TRACE("seq", tout << "Fixed: " << mk_pp(e, m) << " " << lo << "\n";); TRACE("seq", tout << "Fixed: " << mk_pp(e, m) << " " << lo << "\n";);
add_axiom(~mk_eq(m_util.str.mk_length(e), m_autil.mk_numeral(lo, true), false), mk_seq_eq(seq, e)); add_axiom(~mk_eq(m_util.str.mk_length(e), m_autil.mk_numeral(lo, true), false), mk_seq_eq(seq, e));
if (!ctx.at_base_level()) { if (!ctx.at_base_level()) {