Skip to content

Commit 76b3198

Browse files
mtrberziNikolajBjorner
authored andcommitted
z3str3: fixes to str.indexof when axiomatizing constant expressions
1 parent 0acbdff commit 76b3198

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/smt/theory_str.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,23 @@ namespace smt {
13351335
return;
13361336
}
13371337
SASSERT(ex->get_num_args() == 3);
1338+
1339+
{
1340+
// Attempt to rewrite to an integer constant. If this succeeds,
1341+
// assert equality with that constant.
1342+
// The rewriter normally takes care of this for terms that are in scope
1343+
// at the beginning of the search.
1344+
// We perform the check here to catch terms that are added during the search.
1345+
expr_ref rwex(ex, m);
1346+
rw(rwex);
1347+
if (m_autil.is_numeral(rwex)) {
1348+
TRACE("str", tout << "constant expression " << mk_pp(ex, m) << " simplifies to " << mk_pp(rwex, m) << std::endl;);
1349+
assert_axiom(ctx.mk_eq_atom(ex, rwex));
1350+
axiomatized_terms.insert(ex);
1351+
return;
1352+
}
1353+
}
1354+
13381355
// if the third argument is exactly the integer 0, we can use this "simple" indexof;
13391356
// otherwise, we call the "extended" version
13401357
expr * startingPosition = ex->get_arg(2);
@@ -1516,6 +1533,7 @@ namespace smt {
15161533
{
15171534
expr_ref premise(m.mk_not(u.str.mk_contains(H, N)), m);
15181535
expr_ref conclusion(ctx.mk_eq_atom(e, minus_one), m);
1536+
rw(premise);
15191537
assert_implication(premise, conclusion);
15201538
}
15211539
// case 4: 0 < i < len(H), N non-empty, and H contains N

0 commit comments

Comments
 (0)