mirror of
https://github.com/Z3Prover/z3
synced 2025-04-06 17:44:08 +00:00
add length coherence check for length = 0
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
f34a54fea0
commit
0870b4a5a0
|
@ -785,7 +785,6 @@ bool seq_decl_plugin::is_value(app* e) const {
|
|||
e = to_app(e->get_arg(1));
|
||||
continue;
|
||||
}
|
||||
TRACE("seq", tout << mk_pp(e, *m_manager) << "\n";);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -600,7 +600,7 @@ bool theory_seq::fixed_length() {
|
|||
|
||||
bool theory_seq::fixed_length(expr* e) {
|
||||
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;
|
||||
}
|
||||
if (is_skolem(m_tail, e) || is_skolem(m_seq_first, e) ||
|
||||
|
@ -609,21 +609,28 @@ bool theory_seq::fixed_length(expr* e) {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
context& ctx = get_context();
|
||||
|
||||
m_trail_stack.push(insert_obj_trail<theory_seq, expr>(m_fixed, e));
|
||||
m_fixed.insert(e);
|
||||
|
||||
unsigned _lo = lo.get_unsigned();
|
||||
expr_ref seq(e, m), head(m), tail(m);
|
||||
expr_ref_vector elems(m);
|
||||
|
||||
for (unsigned j = 0; j < _lo; ++j) {
|
||||
mk_decompose(seq, head, tail);
|
||||
elems.push_back(head);
|
||||
seq = tail;
|
||||
|
||||
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);
|
||||
|
||||
for (unsigned j = 0; j < _lo; ++j) {
|
||||
mk_decompose(seq, head, tail);
|
||||
elems.push_back(head);
|
||||
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";);
|
||||
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()) {
|
||||
|
|
Loading…
Reference in a new issue