mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 09:05:31 +00:00
* fixing issue #4651 * regression fix * fix #4662 Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * reenabled lift_ites_throttled with an additional filter, without the filter finding the model in report #4651 goes from .02s to 20s, also updated pretty printing of regexes to be more accurate * removing temp testing variable * Allow to skip System.loadLibrary() calls from Java Native class (#4667) * using intended utility methods for sort detection * adding ack/model Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * add smt params dependency Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * missing file Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * deps Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * order Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * persist fields Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * dbg build Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * reset caches Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * sr Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * fix cmake build Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * shuffle dependencies Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * warnings /errors Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * update include Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * missing cmakelists Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * update cmake Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * add depend Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * add depend Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * virtual method Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * path Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * move parameters from ast/rewriter to params Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * move fpa Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * fix warnings Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * remove pragma Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * dbg Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * updated sat_smt Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * fix #4651 Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * encoding options #4665 Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * expose name inclusion as optional Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * fix misc issues around #4661 introduced when adding lazy push/pop to selected theories Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * remove lazy push from theory_lra Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * fix dotnet build Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * release nodes Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * free memory in egraph Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * avoid duplicate class names frame in sat_scc and sat_smt Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * adding euf Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * elaborate on smt/drat format outline, expose euf mode as config Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * mk-var during copy Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * move theory_var_list into id_var_list and utilities from smt-enode into it, prepare for theory variables in egraph Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * with bounded Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * Remove duplicate binary condition. Fixes #4668. * butterfly effect on fp? Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * prepare for theory plugins Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * file Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * build fix * remove SMTFD Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * na Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com> * SMTFD is back (#4676) * fixing issue #4651 * regression fix * reenabled lift_ites_throttled with an additional filter, without the filter finding the model in report #4651 goes from .02s to 20s, also updated pretty printing of regexes to be more accurate * removing temp testing variable * using intended utility methods for sort detection * misc edits related to nonground regexes * bug fix of state id off by 1 calculation error and improved pretty printing with regex tooltip generated in dgml state graph * removed unused method declaration * improved id to regex value map info in generated dgml * reorgd callback function for state pretty printer * updated some comments Co-authored-by: Nikolaj Bjorner <nbjorner@microsoft.com> Co-authored-by: Sergey Vladimirov <vlsergey@gmail.com> Co-authored-by: Christoph M. Wintersteiger <cwinter@microsoft.com> Co-authored-by: Arie Gurfinkel <arie.gurfinkel@gmail.com>
This commit is contained in:
parent
d02b0cde7a
commit
af54a79acc
8 changed files with 280 additions and 54 deletions
|
@ -25,8 +25,8 @@ namespace smt {
|
|||
th(th),
|
||||
ctx(th.get_context()),
|
||||
m(th.get_manager()),
|
||||
m_state_to_expr(m)
|
||||
{}
|
||||
m_state_to_expr(m),
|
||||
m_state_graph(state_graph::state_pp(this, pp_state)) { }
|
||||
|
||||
seq_util& seq_regex::u() { return th.m_util; }
|
||||
class seq_util::rex& seq_regex::re() { return th.m_util.re; }
|
||||
|
@ -143,13 +143,46 @@ namespace smt {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
//if r is uninterpreted then taking a derivative may diverge try to obtain the
|
||||
//value from equations providing r a definition
|
||||
if (is_uninterp(r)) {
|
||||
if (m_const_to_expr.contains(r)) {
|
||||
proof* _not_used = nullptr;
|
||||
m_const_to_expr.get(r, r, _not_used);
|
||||
if (is_uninterp(r)) {
|
||||
if (m_const_to_expr.contains(r)) {
|
||||
m_const_to_expr.get(r, r, _not_used);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//add the literal back
|
||||
expr_ref r_alias(m.mk_fresh_const(symbol(r->get_id()), m.get_sort(r), false), m);
|
||||
expr_ref s_in_r_alias(re().mk_in_re(s, r_alias), m);
|
||||
literal s_in_r_alias_lit = th.mk_literal(s_in_r_alias);
|
||||
m_const_to_expr.insert(r_alias, r, nullptr);
|
||||
th.add_axiom(s_in_r_alias_lit);
|
||||
return;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
if (is_uninterp(r)) {
|
||||
th.add_unhandled_expr(e);
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
expr_ref zero(a().mk_int(0), m);
|
||||
expr_ref acc = sk().mk_accept(s, zero, r);
|
||||
expr_ref acc(sk().mk_accept(s, zero, r), m);
|
||||
literal acc_lit = th.mk_literal(acc);
|
||||
|
||||
TRACE("seq", tout << "propagate " << acc << "\n";);
|
||||
|
||||
th.propagate_lit(nullptr, 1, &lit, acc_lit);
|
||||
//th.propagate_lit(nullptr, 1, &lit, acc_lit);
|
||||
th.add_axiom(~lit, acc_lit);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -363,9 +396,11 @@ namespace smt {
|
|||
|
||||
expr_ref seq_regex::symmetric_diff(expr* r1, expr* r2) {
|
||||
expr_ref r(m);
|
||||
if (re().is_empty(r1))
|
||||
std::swap(r1, r2);
|
||||
if (re().is_empty(r2))
|
||||
if (r1 == r2)
|
||||
r = re().mk_empty(m.get_sort(r1));
|
||||
else if (re().is_empty(r1))
|
||||
r = r2;
|
||||
else if (re().is_empty(r2))
|
||||
r = r1;
|
||||
else
|
||||
r = re().mk_union(re().mk_diff(r1, r2), re().mk_diff(r2, r1));
|
||||
|
@ -439,19 +474,40 @@ namespace smt {
|
|||
TRACE("seq_regex", tout << "propagate EQ: " << mk_pp(r1, m) << ", " << mk_pp(r2, m) << std::endl;);
|
||||
STRACE("seq_regex_brief", tout << "PEQ ";);
|
||||
|
||||
/*
|
||||
if (is_uninterp(r1) || is_uninterp(r2)) {
|
||||
th.add_axiom(th.mk_eq(r1, r2, false));
|
||||
if (is_uninterp(r1))
|
||||
m_const_to_expr.insert(r1, r2, nullptr);
|
||||
else
|
||||
m_const_to_expr.insert(r2, r1, nullptr);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
sort* seq_sort = nullptr;
|
||||
VERIFY(u().is_re(r1, seq_sort));
|
||||
expr_ref r = symmetric_diff(r1, r2);
|
||||
expr_ref r = symmetric_diff(r1, r2);
|
||||
if (re().is_empty(r))
|
||||
//trivially true
|
||||
return;
|
||||
expr_ref emp(re().mk_empty(m.get_sort(r)), m);
|
||||
expr_ref n(m.mk_fresh_const("re.char", seq_sort), m);
|
||||
expr_ref is_empty = sk().mk_is_empty(r, r, n);
|
||||
expr_ref f(m.mk_fresh_const("re.char", seq_sort), m);
|
||||
expr_ref is_empty = sk().mk_is_empty(r, r, f);
|
||||
// is_empty : (re,re,seq) -> Bool is a Skolem function
|
||||
// f is a fresh internal Skolem constant of sort seq
|
||||
// the literal is satisfiable when emptiness check succeeds
|
||||
// meaning that r is not nullable and
|
||||
// that all derivatives of r (if any) are also empty
|
||||
// TBD: rewrite to use state_graph
|
||||
th.add_axiom(~th.mk_eq(r1, r2, false), th.mk_literal(is_empty));
|
||||
}
|
||||
|
||||
void seq_regex::propagate_ne(expr* r1, expr* r2) {
|
||||
TRACE("seq_regex", tout << "propagate NEQ: " << mk_pp(r1, m) << ", " << mk_pp(r2, m) << std::endl;);
|
||||
STRACE("seq_regex_brief", tout << "PNEQ ";);
|
||||
|
||||
// TBD: rewrite to use state_graph
|
||||
// why is is_non_empty even needed, why not just not(in_empty)
|
||||
sort* seq_sort = nullptr;
|
||||
VERIFY(u().is_re(r1, seq_sort));
|
||||
expr_ref r = symmetric_diff(r1, r2);
|
||||
|
@ -566,6 +622,29 @@ namespace smt {
|
|||
_temp_bool_owner.push_back(b);
|
||||
re_to_bool.find(e) = b;
|
||||
}
|
||||
/*
|
||||
else if (re().is_empty(e))
|
||||
{
|
||||
re_to_bool.find(e) = m.mk_false();
|
||||
}
|
||||
else if (re().is_epsilon(e))
|
||||
{
|
||||
expr* iplus1 = a().mk_int(i);
|
||||
expr* one = a().mk_int(1);
|
||||
_temp_bool_owner.push_back(iplus1);
|
||||
_temp_bool_owner.push_back(one);
|
||||
//the substring starting after position iplus1 must be empty
|
||||
expr* s_end = str().mk_substr(s, iplus1, one);
|
||||
expr* s_end_is_epsilon = m.mk_eq(s_end, str().mk_empty(m.get_sort(s)));
|
||||
|
||||
_temp_bool_owner.push_back(s_end_is_epsilon);
|
||||
re_to_bool.find(e) = s_end_is_epsilon;
|
||||
|
||||
STRACE("seq_regex_verbose", tout
|
||||
<< "added empty sequence leaf: "
|
||||
<< mk_pp(s_end_is_epsilon, m) << std::endl;);
|
||||
}
|
||||
*/
|
||||
else if (re().is_union(e, e1, e2)) {
|
||||
expr* b1 = re_to_bool.find(e1);
|
||||
expr* b2 = re_to_bool.find(e2);
|
||||
|
@ -760,13 +839,14 @@ namespace smt {
|
|||
STRACE("seq_regex", tout
|
||||
<< "New state ID: " << new_id
|
||||
<< " = " << mk_pp(e, m) << std::endl;);
|
||||
SASSERT(get_expr_from_id(new_id) == e);
|
||||
}
|
||||
return m_expr_to_state.find(e);
|
||||
}
|
||||
expr* seq_regex::get_expr_from_id(unsigned id) {
|
||||
SASSERT(id >= 1);
|
||||
SASSERT(id <= m_state_to_expr.size());
|
||||
return m_state_to_expr.get(id);
|
||||
return m_state_to_expr.get(id - 1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -114,6 +114,8 @@ namespace smt {
|
|||
state_graph m_state_graph;
|
||||
ptr_addr_map<expr, unsigned> m_expr_to_state;
|
||||
expr_ref_vector m_state_to_expr;
|
||||
/* map from uninterpreted regex constants to assigned regex expressions by EQ */
|
||||
// expr_map m_const_to_expr;
|
||||
unsigned m_max_state_graph_size { 10000 };
|
||||
// Convert between expressions and states (IDs)
|
||||
unsigned get_state_id(expr* e);
|
||||
|
@ -166,6 +168,22 @@ namespace smt {
|
|||
void get_cofactors_rec(expr* r, expr_ref_vector& conds,
|
||||
expr_ref_pair_vector& result);
|
||||
|
||||
/*
|
||||
Pretty print the regex of the state id to the out stream,
|
||||
seq_regex_ptr must be a pointer to seq_regex and the
|
||||
id must be a valid state id or else nothing is printed.
|
||||
*/
|
||||
static void pp_state(void* seq_regex_ptr, std::ostream& out, unsigned id, bool html_encode) {
|
||||
seq_regex* sr = (seq_regex*)seq_regex_ptr;
|
||||
if (sr) {
|
||||
seq_util::rex re_util(sr->re());
|
||||
if (1 <= id && id <= sr->m_state_to_expr.size()) {
|
||||
expr* r = sr->get_expr_from_id(id);
|
||||
seq_util::rex::pp(re_util, r, html_encode).display(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
seq_regex(theory_seq& th);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue