3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-11 09:44:43 +00:00

z3str3: use rational in place of unsigned during model construction

This commit is contained in:
Murphy Berzish 2020-05-13 14:32:44 -04:00
parent 127ef59ce4
commit 5e7806c4a4
3 changed files with 36 additions and 27 deletions

View file

@ -624,17 +624,16 @@ namespace smt {
cex = expr_ref(m_autil.mk_ge(mk_strlen(term), mk_int(0)), m);
return false;
}
SASSERT(varLen_value.is_unsigned() && "actually arithmetic solver can assign it a very large number");
TRACE("str_fl", tout << "creating character terms for variable " << mk_pp(term, m) << ", length = " << varLen_value << std::endl;);
ptr_vector<expr> new_chars;
for (unsigned i = 0; i < varLen_value.get_unsigned(); ++i) {
for (rational i = rational::zero(); i < varLen_value; ++i) {
// TODO we can probably name these better for the sake of debugging
expr_ref ch(mk_fresh_const("char", bv8_sort), m);
new_chars.push_back(ch);
fixed_length_subterm_trail.push_back(ch);
}
var_to_char_subterm_map.insert(term, new_chars);
fixed_length_used_len_terms.insert(term, varLen_value.get_unsigned());
fixed_length_used_len_terms.insert(term, varLen_value);
}
var_to_char_subterm_map.find(term, eqc_chars);
} else if (u.str.is_concat(term, arg0, arg1)) {
@ -754,13 +753,13 @@ namespace smt {
}
TRACE("str_fl", tout << "creating character terms for uninterpreted function " << mk_pp(term, m) << ", length = " << ufLen_value << std::endl;);
ptr_vector<expr> new_chars;
for (unsigned i = 0; i < ufLen_value.get_unsigned(); ++i) {
for (rational i = rational::zero(); i < ufLen_value; ++i) {
expr_ref ch(mk_fresh_const("char", bv8_sort), m);
new_chars.push_back(ch);
fixed_length_subterm_trail.push_back(ch);
}
uninterpreted_to_char_subterm_map.insert(term, new_chars);
fixed_length_used_len_terms.insert(term, ufLen_value.get_unsigned());
fixed_length_used_len_terms.insert(term, ufLen_value);
}
uninterpreted_to_char_subterm_map.find(term, eqc_chars);
}
@ -794,7 +793,6 @@ namespace smt {
fixed_length_assumptions.push_back(_e);
fixed_length_lesson.insert(_e, std::make_tuple(rational(i), lhs, rhs));
}
// fixed_length_used_len_terms.push_back(get_context().mk_eq_atom(lhs, rhs));
return true;
}
@ -1056,7 +1054,8 @@ namespace smt {
for (auto e : fixed_length_used_len_terms) {
expr * var = &e.get_key();
precondition.push_back(m.mk_eq(u.str.mk_length(var), mk_int(e.get_value())));
rational val = e.get_value();
precondition.push_back(m.mk_eq(u.str.mk_length(var), mk_int(val)));
}
TRACE("str_fl",
@ -1172,7 +1171,8 @@ namespace smt {
TRACE("str_fl", tout << "subsolver found UNSAT; constructing length counterexample" << std::endl;);
for (auto e : fixed_length_used_len_terms) {
expr * var = &e.get_key();
cex.push_back(m.mk_eq(u.str.mk_length(var), mk_int(e.get_value())));
rational val = e.get_value();
cex.push_back(m.mk_eq(u.str.mk_length(var), mk_int(val)));
}
return l_false;
} else {