3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2018-07-26 15:31:49 +01:00
parent 8744c62fca
commit 60bb02b709
11 changed files with 120 additions and 35 deletions

View file

@ -401,11 +401,11 @@ namespace smt {
label_hasher & m_lbl_hasher;
func_decl * m_root_lbl;
unsigned m_num_args; //!< we need this information to avoid the nary *,+ crash bug
unsigned char m_filter_candidates;
bool m_filter_candidates;
unsigned m_num_regs;
unsigned m_num_choices;
instruction * m_root;
enode_vector m_candidates;
obj_hashtable<enode> m_candidates;
#ifdef Z3DEBUG
context * m_context;
ptr_vector<app> m_patterns;
@ -531,7 +531,7 @@ namespace smt {
}
bool filter_candidates() const {
return m_filter_candidates != 0;
return m_filter_candidates;
}
const instruction * get_root() const {
@ -539,7 +539,7 @@ namespace smt {
}
void add_candidate(enode * n) {
m_candidates.push_back(n);
m_candidates.insert(n);
}
bool has_candidates() const {
@ -550,7 +550,7 @@ namespace smt {
m_candidates.reset();
}
enode_vector const & get_candidates() const {
obj_hashtable<enode> const & get_candidates() const {
return m_candidates;
}
@ -2001,7 +2001,9 @@ namespace smt {
TRACE("trigger_bug", tout << "execute for code tree:\n"; t->display(tout););
init(t);
if (t->filter_candidates()) {
//t->display(std::cout << "ncf: " << t->get_candidates().size() << "\n");
for (enode* app : t->get_candidates()) {
TRACE("trigger_bug", tout << "candidate\n" << mk_ismt2_pp(app->get_owner(), m_ast_manager) << "\n";);
if (!app->is_marked() && app->is_cgr()) {
if (m_context.resource_limits_exceeded() || !execute_core(t, app))
return;
@ -2014,6 +2016,9 @@ namespace smt {
}
}
else {
//t->display(std::cout << "ncu: " << t->get_candidates().size() << "\n");
//for (enode* app : t->get_candidates()) { std::cout << expr_ref(app->get_owner(), m_ast_manager) << "\n"; }
//std::cout.flush();
for (enode* app : t->get_candidates()) {
TRACE("trigger_bug", tout << "candidate\n" << mk_ismt2_pp(app->get_owner(), m_ast_manager) << "\n";);
if (app->is_cgr()) {
@ -3516,9 +3521,7 @@ namespace smt {
std::cout << "Avg. " << static_cast<double>(total_sz)/static_cast<double>(counter) << ", Max. " << max_sz << "\n";
#endif
enode_vector::iterator it1 = v->begin();
enode_vector::iterator end1 = v->end();
for (; it1 != end1; ++it1) {
for (enode* n : *v) {
// Two different kinds of mark are used:
// - enode mark field: it is used to mark the already processed parents.
// - enode mark2 field: it is used to mark the roots already added to be processed in the next level.
@ -3527,7 +3530,7 @@ namespace smt {
// and Z3 may fail to find potential new matches.
//
// The file regression\acu.sx exposed this problem.
enode * curr_child = (*it1)->get_root();
enode * curr_child = n->get_root();
if (m_use_filters && curr_child->get_plbls().empty_intersection(filter))
continue;
@ -3591,7 +3594,7 @@ namespace smt {
is_eq(curr_tree->m_ground_arg, curr_parent->get_arg(curr_tree->m_ground_arg_idx))
)) {
if (curr_tree->m_code) {
TRACE("mam_path_tree", tout << "found candidate\n";);
TRACE("mam_path_tree", tout << "found candidate " << expr_ref(curr_parent->get_owner(), m_ast_manager) << "\n";);
add_candidate(curr_tree->m_code, curr_parent);
}
if (curr_tree->m_first_child) {

View file

@ -1351,18 +1351,9 @@ namespace smt {
\remark The method assign_eq adds a new entry on this queue.
*/
bool context::propagate_eqs() {
for (unsigned i = 0; i < m_eq_propagation_queue.size(); i++) {
TRACE("add_eq", tout << m_eq_propagation_queue.size() << "\n";);
for (unsigned i = 0; i < m_eq_propagation_queue.size() && !get_cancel_flag(); i++) {
new_eq & entry = m_eq_propagation_queue[i];
#if 0
static unsigned counter1 = 0;
static unsigned counter2 = 0;
if (entry.m_lhs->is_eq() || entry.m_rhs->is_eq())
counter1++;
else
counter2++;
if ((counter1 + counter2) % 10000 == 0)
std::cout << counter1 << " " << counter2 << "\n";
#endif
add_eq(entry.m_lhs, entry.m_rhs, entry.m_justification);
if (inconsistent())
return false;
@ -1376,7 +1367,7 @@ namespace smt {
*/
bool context::propagate_atoms() {
SASSERT(!inconsistent());
for (unsigned i = 0; i < m_atom_propagation_queue.size(); i++) {
for (unsigned i = 0; i < m_atom_propagation_queue.size() && !get_cancel_flag(); i++) {
SASSERT(!inconsistent());
literal l = m_atom_propagation_queue[i];
bool_var v = l.var();
@ -1558,16 +1549,17 @@ namespace smt {
lbool context::get_assignment(expr * n) const {
if (m_manager.is_false(n))
return l_false;
if (m_manager.is_not(n))
return ~get_assignment_core(to_app(n)->get_arg(0));
expr* arg = nullptr;
if (m_manager.is_not(n, arg))
return ~get_assignment_core(arg);
return get_assignment_core(n);
}
lbool context::find_assignment(expr * n) const {
if (m_manager.is_false(n))
return l_false;
if (m_manager.is_not(n)) {
expr * arg = to_app(n)->get_arg(0);
expr* arg = nullptr;
if (m_manager.is_not(n, arg)) {
if (b_internalized(arg))
return ~get_assignment_core(arg);
return l_undef;
@ -1752,6 +1744,10 @@ namespace smt {
return false;
if (!propagate_eqs())
return false;
if (get_cancel_flag()) {
m_qhead = qhead;
return true;
}
propagate_th_eqs();
propagate_th_diseqs();
if (inconsistent())
@ -3264,6 +3260,7 @@ namespace smt {
}
void context::reset_assumptions() {
TRACE("unsat_core_bug", tout << "reset " << m_assumptions << "\n";);
for (literal lit : m_assumptions)
get_bdata(lit.var()).m_assumption = false;
m_assumptions.reset();
@ -4106,9 +4103,7 @@ namespace smt {
}
SASSERT(!inconsistent());
unsigned sz = m_b_internalized_stack.size();
for (unsigned i = 0; i < sz; i++) {
expr * curr = m_b_internalized_stack.get(i);
for (expr * curr : m_b_internalized_stack) {
if (is_relevant(curr) && get_assignment(curr) == l_true) {
// if curr is a label literal, then its tags will be copied to result.
m_manager.is_label_lit(curr, result);
@ -4124,9 +4119,7 @@ namespace smt {
void context::get_relevant_labeled_literals(bool at_lbls, expr_ref_vector & result) {
SASSERT(!inconsistent());
buffer<symbol> lbls;
unsigned sz = m_b_internalized_stack.size();
for (unsigned i = 0; i < sz; i++) {
expr * curr = m_b_internalized_stack.get(i);
for (expr * curr : m_b_internalized_stack) {
if (is_relevant(curr) && get_assignment(curr) == l_true) {
lbls.reset();
if (m_manager.is_label_lit(curr, lbls)) {

View file

@ -491,7 +491,7 @@ namespace smt {
}
bool tracking_assumptions() const {
return m_search_lvl > m_base_lvl;
return !m_assumptions.empty() && m_search_lvl > m_base_lvl;
}
expr * bool_var2expr(bool_var v) const {
@ -1011,6 +1011,7 @@ namespace smt {
void push_eq(enode * lhs, enode * rhs, eq_justification const & js) {
SASSERT(lhs != rhs);
SASSERT(lhs->get_root() != rhs->get_root());
m_eq_propagation_queue.push_back(new_eq(lhs, rhs, js));
}

View file

@ -5163,7 +5163,21 @@ void theory_seq::assign_eh(bool_var v, bool is_true) {
}
}
else if (m_util.str.is_contains(e, e1, e2)) {
if (is_true) {
expr_ref_vector disj(m);
if (m_seq_rewrite.reduce_contains(e1, e2, disj)) {
literal_vector lits;
literal lit = mk_literal(e);
lits.push_back(~lit);
for (expr* d : disj) {
lits.push_back(mk_literal(d));
}
++m_stats.m_add_axiom;
ctx.mk_th_axiom(get_id(), lits.size(), lits.c_ptr());
for (expr* d : disj) {
add_axiom(lit, ~mk_literal(d));
}
}
else if (is_true) {
expr_ref f1 = mk_skolem(m_indexof_left, e1, e2);
expr_ref f2 = mk_skolem(m_indexof_right, e1, e2);
f = mk_concat(f1, e2, f2);