mirror of
https://github.com/Z3Prover/z3
synced 2025-06-06 22:23:22 +00:00
handle undefined constant cases for int.to.str
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
893bcbb585
commit
ead704f52f
2 changed files with 23 additions and 5 deletions
|
@ -1082,9 +1082,19 @@ br_status seq_rewriter::mk_str_stoi(expr* a, expr_ref& result) {
|
||||||
if (m_util.str.is_string(a, str)) {
|
if (m_util.str.is_string(a, str)) {
|
||||||
std::string s = str.encode();
|
std::string s = str.encode();
|
||||||
for (unsigned i = 0; i < s.length(); ++i) {
|
for (unsigned i = 0; i < s.length(); ++i) {
|
||||||
if (s[i] == '-') { if (i != 0) return BR_FAILED; }
|
if (s[i] == '-') {
|
||||||
else if ('0' <= s[i] && s[i] <= '9') continue;
|
if (i != 0) {
|
||||||
return BR_FAILED;
|
result = m_autil.mk_int(-1);
|
||||||
|
return BR_DONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ('0' <= s[i] && s[i] <= '9') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
result = m_autil.mk_int(-1);
|
||||||
|
return BR_DONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
rational r(s.c_str());
|
rational r(s.c_str());
|
||||||
result = m_autil.mk_numeral(r, true);
|
result = m_autil.mk_numeral(r, true);
|
||||||
|
|
|
@ -520,7 +520,7 @@ bool theory_seq::branch_variable_mb() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE("seq", tout << "branch_variable_mb\n";);
|
CTRACE("seq", change, tout << "branch_variable_mb\n";);
|
||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2348,7 +2348,14 @@ bool theory_seq::add_stoi_axiom(expr* e) {
|
||||||
rational val;
|
rational val;
|
||||||
TRACE("seq", tout << mk_pp(e, m) << "\n";);
|
TRACE("seq", tout << mk_pp(e, m) << "\n";);
|
||||||
VERIFY(m_util.str.is_stoi(e, n));
|
VERIFY(m_util.str.is_stoi(e, n));
|
||||||
if (get_num_value(e, val) && !m_stoi_axioms.contains(val)) {
|
if (!get_num_value(e, val)) {
|
||||||
|
literal l = mk_literal(m_autil.mk_ge(e, arith_util(m).mk_int(-1)));
|
||||||
|
add_axiom(l);
|
||||||
|
TRACE("seq", tout << l << " " << ctx.get_assignment(l) << "\n";
|
||||||
|
ctx.display(tout););
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (!m_stoi_axioms.contains(val)) {
|
||||||
m_stoi_axioms.insert(val);
|
m_stoi_axioms.insert(val);
|
||||||
if (!val.is_minus_one()) {
|
if (!val.is_minus_one()) {
|
||||||
app_ref e1(m_util.str.mk_string(symbol(val.to_string().c_str())), m);
|
app_ref e1(m_util.str.mk_string(symbol(val.to_string().c_str())), m);
|
||||||
|
@ -3467,6 +3474,7 @@ bool theory_seq::get_num_value(expr* e, rational& val) const {
|
||||||
next = next->get_next();
|
next = next->get_next();
|
||||||
}
|
}
|
||||||
while (next != n);
|
while (next != n);
|
||||||
|
TRACE("seq", tout << "no value for " << mk_pp(e, m) << "\n";);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue