3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-01 12:55:52 +00:00

synchronize fork

This commit is contained in:
nilsbecker 2018-07-06 16:17:56 +02:00 committed by nilsbecker
commit 820c14ed06
430 changed files with 19930 additions and 13462 deletions

View file

@ -16,15 +16,16 @@ Author:
Revision History:
--*/
#include "smt/mam.h"
#include "smt/smt_context.h"
#include <algorithm>
#include "util/pool.h"
#include "ast/ast_pp.h"
#include "ast/ast_ll_pp.h"
#include "util/trail.h"
#include "util/stopwatch.h"
#include "ast/ast_pp.h"
#include "ast/ast_ll_pp.h"
#include "ast/ast_smt2_pp.h"
#include<algorithm>
#include "smt/mam.h"
#include "smt/smt_context.h"
// #define _PROFILE_MAM
@ -569,9 +570,8 @@ namespace smt {
if (m_context) {
ast_manager & m = m_context->get_manager();
out << "patterns:\n";
for (expr* p : m_patterns) {
out << mk_pp(p, m) << "\n";
}
for (app* a : m_patterns)
out << mk_pp(a, m) << "\n";
}
#endif
out << "function: " << m_root_lbl->get_name();
@ -1482,8 +1482,8 @@ namespace smt {
}
if (num_instr > SIMPLE_SEQ_THRESHOLD || (curr != nullptr && curr->m_opcode == CHOOSE))
simple = false;
for (unsigned reg : m_to_reset)
m_registers[reg] = 0;
for (unsigned r : m_to_reset)
m_registers[r] = 0;
return weight;
}
@ -2001,30 +2001,32 @@ namespace smt {
TRACE("trigger_bug", tout << "execute for code tree:\n"; t->display(tout););
init(t);
if (t->filter_candidates()) {
for (enode * app : t->get_candidates()) {
for (enode* app : t->get_candidates()) {
if (!app->is_marked() && app->is_cgr()) {
execute_core(t, app);
if (m_context.resource_limits_exceeded() || !execute_core(t, app))
return;
app->set_mark();
}
}
for (enode * app : t->get_candidates()) {
for (enode* app : t->get_candidates()) {
if (app->is_marked())
app->unset_mark();
}
}
else {
for (enode * app : t->get_candidates()) {
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()) {
TRACE("trigger_bug", tout << "is_cgr\n";);
execute_core(t, app);
if (m_context.resource_limits_exceeded() || !execute_core(t, app))
return;
}
}
}
}
// init(t) must be invoked before execute_core
void execute_core(code_tree * t, enode * n);
bool execute_core(code_tree * t, enode * n);
// Return the min, max generation of the enodes in m_pattern_instances.
@ -2253,7 +2255,7 @@ namespace smt {
display_instr_input_reg(out, m_pc);
}
void interpreter::execute_core(code_tree * t, enode * n) {
bool interpreter::execute_core(code_tree * t, enode * n) {
TRACE("trigger_bug", tout << "interpreter::execute_core\n"; t->display(tout); tout << "\nenode\n" << mk_ismt2_pp(n->get_owner(), m_ast_manager) << "\n";);
unsigned since_last_check = 0;
@ -2501,7 +2503,7 @@ namespace smt {
#define ON_MATCH(NUM) \
m_max_generation = std::max(m_max_generation, get_max_generation(NUM, m_bindings.begin())); \
if (m_context.get_cancel_flag()) { \
return; \
return false; \
} \
m_mam.on_match(static_cast<const yield *>(m_pc)->m_qa, \
static_cast<const yield *>(m_pc)->m_pat, \
@ -2654,7 +2656,7 @@ namespace smt {
#ifdef _PROFILE_MAM
t->get_watch().stop();
#endif
return; // no more alternatives
return true; // no more alternatives
}
backtrack_point & bp = m_backtrack_stack[m_top - 1];
m_max_generation = bp.m_old_max_generation;
@ -2682,7 +2684,7 @@ namespace smt {
#ifdef _PROFILE_MAM
t->get_watch().stop();
#endif
return;
return false;
}
}
@ -2800,11 +2802,12 @@ namespace smt {
default:
UNREACHABLE();
}
return false;
} // end of execute_core
void display_trees(std::ostream & out, const ptr_vector<code_tree> & trees) {
unsigned lbl = 0;
for (code_tree* tree : trees) {
for (code_tree * tree : trees) {
if (tree) {
out << "tree for f" << lbl << "\n";
out << *tree;
@ -3150,10 +3153,7 @@ namespace smt {
m_trail_stack.push(set_bitvector_trail<mam_impl>(m_is_clbl, lbl_id));
SASSERT(m_is_clbl[lbl_id]);
unsigned h = m_lbl_hasher(lbl);
enode_vector::const_iterator it = m_context.begin_enodes_of(lbl);
enode_vector::const_iterator end = m_context.end_enodes_of(lbl);
for (; it != end; ++it) {
enode * app = *it;
for (enode* app : m_context.enodes_of(lbl)) {
if (m_context.is_relevant(app)) {
update_lbls(app, h);
TRACE("mam_bug", tout << "updating labels of: #" << app->get_owner_id() << "\n";
@ -3195,10 +3195,7 @@ namespace smt {
SASSERT(m_is_plbl[lbl_id]);
SASSERT(is_plbl(lbl));
unsigned h = m_lbl_hasher(lbl);
enode_vector::const_iterator it = m_context.begin_enodes_of(lbl);
enode_vector::const_iterator end = m_context.end_enodes_of(lbl);
for (; it != end; ++it) {
enode * app = *it;
for (enode * app : m_context.enodes_of(lbl)) {
if (m_context.is_relevant(app))
update_children_plbls(app, h);
}
@ -3684,18 +3681,12 @@ namespace smt {
approx_set & plbls = r1->get_plbls();
approx_set & clbls = r2->get_lbls();
if (!plbls.empty() && !clbls.empty()) {
approx_set::iterator it1 = plbls.begin();
approx_set::iterator end1 = plbls.end();
for (; it1 != end1; ++it1) {
for (unsigned plbl1 : plbls) {
if (m_context.get_cancel_flag()) {
break;
}
unsigned plbl1 = *it1;
SASSERT(plbls.may_contain(plbl1));
approx_set::iterator it2 = clbls.begin();
approx_set::iterator end2 = clbls.end();
for (; it2 != end2; ++it2) {
unsigned lbl2 = *it2;
for (unsigned lbl2 : clbls) {
SASSERT(clbls.may_contain(lbl2));
collect_parents(r1, m_pc[plbl1][lbl2]);
}
@ -3706,14 +3697,12 @@ namespace smt {
void match_new_patterns() {
TRACE("mam_new_pat", tout << "matching new patterns:\n";);
m_tmp_trees_to_delete.reset();
svector<qp_pair>::iterator it1 = m_new_patterns.begin();
svector<qp_pair>::iterator end1 = m_new_patterns.end();
for (; it1 != end1; ++it1) {
for (auto const& kv : m_new_patterns) {
if (m_context.get_cancel_flag()) {
break;
}
quantifier * qa = it1->first;
app * mp = it1->second;
quantifier * qa = kv.first;
app * mp = kv.second;
SASSERT(m_ast_manager.is_pattern(mp));
app * p = to_app(mp->get_arg(0));
func_decl * lbl = p->get_decl();
@ -3730,19 +3719,13 @@ namespace smt {
}
}
ptr_vector<func_decl>::iterator it2 = m_tmp_trees_to_delete.begin();
ptr_vector<func_decl>::iterator end2 = m_tmp_trees_to_delete.end();
for (; it2 != end2; ++it2) {
func_decl * lbl = *it2;
for (func_decl * lbl : m_tmp_trees_to_delete) {
unsigned lbl_id = lbl->get_decl_id();
code_tree * tmp_tree = m_tmp_trees[lbl_id];
SASSERT(tmp_tree != 0);
SASSERT(m_context.get_num_enodes_of(lbl) > 0);
m_interpreter.init(tmp_tree);
enode_vector::const_iterator it3 = m_context.begin_enodes_of(lbl);
enode_vector::const_iterator end3 = m_context.end_enodes_of(lbl);
for (; it3 != end3; ++it3) {
enode * app = *it3;
for (enode * app : m_context.enodes_of(lbl)) {
if (m_context.is_relevant(app))
m_interpreter.execute_core(tmp_tree, app);
}
@ -3831,10 +3814,7 @@ namespace smt {
void pop_scope(unsigned num_scopes) override {
if (!m_to_match.empty()) {
ptr_vector<code_tree>::iterator it = m_to_match.begin();
ptr_vector<code_tree>::iterator end = m_to_match.end();
for (; it != end; ++it) {
code_tree * t = *it;
for (code_tree* t : m_to_match) {
t->reset_candidates();
}
m_to_match.reset();
@ -3867,10 +3847,7 @@ namespace smt {
void match() override {
TRACE("trigger_bug", tout << "match\n"; display(tout););
ptr_vector<code_tree>::iterator it = m_to_match.begin();
ptr_vector<code_tree>::iterator end = m_to_match.end();
for (; it != end; ++it) {
code_tree * t = *it;
for (code_tree* t : m_to_match) {
SASSERT(t->has_candidates());
m_interpreter.execute(t);
t->reset_candidates();
@ -3891,10 +3868,7 @@ namespace smt {
if (t) {
m_interpreter.init(t);
func_decl * lbl = t->get_root_lbl();
enode_vector::const_iterator it2 = m_context.begin_enodes_of(lbl);
enode_vector::const_iterator end2 = m_context.end_enodes_of(lbl);
for (; it2 != end2; ++it2) {
enode * curr = *it2;
for (enode * curr : m_context.enodes_of(lbl)) {
if (use_irrelevant || m_context.is_relevant(curr))
m_interpreter.execute_core(t, curr);
}
@ -3931,7 +3905,7 @@ namespace smt {
#endif
unsigned min_gen, max_gen;
m_interpreter.get_min_max_top_generation(min_gen, max_gen);
m_context.add_instance(qa, pat, num_bindings, bindings, max_generation, min_gen, max_gen, used_enodes);
m_context.add_instance(qa, pat, num_bindings, bindings, nullptr, max_generation, min_gen, max_gen, used_enodes);
}
bool is_shared(enode * n) const override {