Skip to content

Commit

Permalink
don't rewrite empty/non-empty checking predicates
Browse files Browse the repository at this point in the history
Signed-off-by: Nikolaj Bjorner <[email protected]>
  • Loading branch information
NikolajBjorner committed Jul 31, 2020
1 parent b4f994b commit 615e2cf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
9 changes: 6 additions & 3 deletions src/smt/seq_regex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,10 @@ namespace smt {
<< "," << expr_id_str(u) << "," << expr_id_str(n) << ") ";);

expr_ref is_nullable = is_nullable_wrapper(r);
if (m.is_true(is_nullable))
if (m.is_true(is_nullable)) {
TRACE("seq_regex", tout << "is nullable\n";);
return;
}
literal null_lit = th.mk_literal(is_nullable);
expr_ref hd = mk_first(r, n);
expr_ref d(m);
Expand All @@ -433,12 +435,13 @@ namespace smt {
rewrite(cond);
if (m.is_false(cond))
continue;
expr_ref next_non_empty = sk().mk_is_non_empty(p.second, re().mk_union(u, r), n);
expr_ref next_non_empty = sk().mk_is_non_empty(p.second, re().mk_union(u, p.second), n);
if (!m.is_true(cond))
next_non_empty = m.mk_and(cond, next_non_empty);
lits.push_back(th.mk_literal(next_non_empty));
}

TRACE("seq_regex", tout << lits << "\n";);
th.add_axiom(lits);
}

Expand Down Expand Up @@ -518,7 +521,7 @@ namespace smt {
expr_ref ncond(mk_not(m, cond), m);
lits.push_back(th.mk_literal(mk_forall(m, hd, ncond)));
}
expr_ref is_empty1 = sk().mk_is_empty(p.second, re().mk_union(u, r), n);
expr_ref is_empty1 = sk().mk_is_empty(p.second, re().mk_union(u, p.second), n);
lits.push_back(th.mk_literal(is_empty1));
th.add_axiom(lits);
}
Expand Down
5 changes: 3 additions & 2 deletions src/smt/seq_skolem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,15 @@ seq_skolem::seq_skolem(ast_manager& m, th_rewriter& rw):
m_is_non_empty = "re.is_non_empty";
}

expr_ref seq_skolem::mk(symbol const& s, expr* e1, expr* e2, expr* e3, expr* e4, sort* range) {
expr_ref seq_skolem::mk(symbol const& s, expr* e1, expr* e2, expr* e3, expr* e4, sort* range, bool rw) {
expr* es[4] = { e1, e2, e3, e4 };
unsigned len = e4?4:(e3?3:(e2?2:(e1?1:0)));
if (!range) {
range = m.get_sort(e1);
}
expr_ref result(seq.mk_skolem(s, len, es, range), m);
m_rewrite(result);
if (rw)
m_rewrite(result);
return result;
}

Expand Down
8 changes: 4 additions & 4 deletions src/smt/seq_skolem.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ namespace smt {
expr_ref mk(symbol const& s, sort* range) { return mk(s, nullptr, nullptr, nullptr, nullptr, range); }
expr_ref mk(symbol const& s, expr* e, sort* range) { return mk(s, e, nullptr, nullptr, nullptr, range); }
expr_ref mk(symbol const& s, expr* e1, expr* e2, sort* range) { return mk(s, e1, e2, nullptr, nullptr, range); }
expr_ref mk(symbol const& s, expr* e1, expr* e2, expr* e3, sort* range) { return mk(s, e1, e2, e3, nullptr, range); }
expr_ref mk(symbol const& s, expr* e1, expr* e2 = nullptr, expr* e3 = nullptr, expr* e4 = nullptr, sort* range = nullptr);
expr_ref mk(symbol const& s, expr* e1, expr* e2, expr* e3, sort* range, bool rw = true) { return mk(s, e1, e2, e3, nullptr, range, rw); }
expr_ref mk(symbol const& s, expr* e1, expr* e2 = nullptr, expr* e3 = nullptr, expr* e4 = nullptr, sort* range = nullptr, bool rw = true);

expr_ref mk(char const* s, sort* range) { return mk(s, nullptr, nullptr, nullptr, nullptr, range); }
expr_ref mk(char const* s, expr* e, sort* range) { return mk(s, e, nullptr, nullptr, nullptr, range); }
Expand All @@ -72,8 +72,8 @@ namespace smt {
}
expr_ref mk_accept(expr_ref_vector const& args) { return expr_ref(seq.mk_skolem(m_accept, args.size(), args.c_ptr(), m.mk_bool_sort()), m); }
expr_ref mk_accept(expr* s, expr* i, expr* r) { return mk(m_accept, s, i, r, nullptr, m.mk_bool_sort()); }
expr_ref mk_is_non_empty(expr* r, expr* u, expr* n) { return mk(m_is_non_empty, r, u, n, m.mk_bool_sort()); }
expr_ref mk_is_empty(expr* r, expr* u, expr* n) { return mk(m_is_empty, r, u, n, m.mk_bool_sort()); }
expr_ref mk_is_non_empty(expr* r, expr* u, expr* n) { return mk(m_is_non_empty, r, u, n, m.mk_bool_sort(), false); }
expr_ref mk_is_empty(expr* r, expr* u, expr* n) { return mk(m_is_empty, r, u, n, m.mk_bool_sort(), false); }

expr_ref mk_indexof_left(expr* t, expr* s, expr* offset = nullptr) { return mk(m_indexof_left, t, s, offset); }
expr_ref mk_indexof_right(expr* t, expr* s, expr* offset = nullptr) { return mk(m_indexof_right, t, s, offset); }
Expand Down

0 comments on commit 615e2cf

Please sign in to comment.