mirror of
https://github.com/Z3Prover/z3
synced 2026-05-31 06:07:46 +00:00
add back cur_path as a local variable
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
9893a09fad
commit
8eaa9d9e6b
4 changed files with 20 additions and 23 deletions
|
|
@ -965,8 +965,7 @@ namespace seq {
|
||||||
return {expr_ref(last_stable_sum, m), last_stable_idx};
|
return {expr_ref(last_stable_sum, m), last_stable_idx};
|
||||||
}
|
}
|
||||||
|
|
||||||
simplify_result nielsen_node::simplify_and_init() {
|
simplify_result nielsen_node::simplify_and_init(ptr_vector<nielsen_edge> const& cur_path) {
|
||||||
svector<nielsen_edge*> const& cur_path = m_graph.cur_path();
|
|
||||||
if (m_is_extended)
|
if (m_is_extended)
|
||||||
return simplify_result::proceed;
|
return simplify_result::proceed;
|
||||||
|
|
||||||
|
|
@ -1495,8 +1494,8 @@ namespace seq {
|
||||||
if (m_max_search_depth > 0 && m_depth_bound > m_max_search_depth)
|
if (m_max_search_depth > 0 && m_depth_bound > m_max_search_depth)
|
||||||
break;
|
break;
|
||||||
inc_run_idx();
|
inc_run_idx();
|
||||||
m_cur_path.reset();
|
ptr_vector<nielsen_edge> cur_path;
|
||||||
search_result r = search_dfs(m_root, 0);
|
search_result r = search_dfs(m_root, cur_path);
|
||||||
IF_VERBOSE(1, verbose_stream()
|
IF_VERBOSE(1, verbose_stream()
|
||||||
<< " depth_bound=" << m_depth_bound << " dfs_nodes=" << m_stats.m_num_dfs_nodes
|
<< " depth_bound=" << m_depth_bound << " dfs_nodes=" << m_stats.m_num_dfs_nodes
|
||||||
<< " max_depth=" << m_stats.m_max_depth << " extensions=" << m_stats.m_num_extensions
|
<< " max_depth=" << m_stats.m_max_depth << " extensions=" << m_stats.m_num_extensions
|
||||||
|
|
@ -1509,7 +1508,7 @@ namespace seq {
|
||||||
IF_VERBOSE(
|
IF_VERBOSE(
|
||||||
1,
|
1,
|
||||||
verbose_stream() << "side constraints: \n";
|
verbose_stream() << "side constraints: \n";
|
||||||
for (auto const &c : m_cur_path.back()->side_constraints()) {
|
for (auto const &c : cur_path.back()->side_constraints()) {
|
||||||
verbose_stream() << " side constraint: " << c.fml << "\n";
|
verbose_stream() << " side constraint: " << c.fml << "\n";
|
||||||
});
|
});
|
||||||
++m_stats.m_num_sat;
|
++m_stats.m_num_sat;
|
||||||
|
|
@ -1534,9 +1533,10 @@ namespace seq {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nielsen_graph::search_result nielsen_graph::search_dfs(nielsen_node* node, unsigned depth) {
|
nielsen_graph::search_result nielsen_graph::search_dfs(nielsen_node* node, ptr_vector<nielsen_edge>& cur_path) {
|
||||||
++m_stats.m_num_dfs_nodes;
|
++m_stats.m_num_dfs_nodes;
|
||||||
// std::cout << m_stats.m_num_dfs_nodes << std::endl;
|
// std::cout << m_stats.m_num_dfs_nodes << std::endl;
|
||||||
|
auto depth = cur_path.size();
|
||||||
m_stats.m_max_depth = std::max(m_stats.m_max_depth, depth);
|
m_stats.m_max_depth = std::max(m_stats.m_max_depth, depth);
|
||||||
|
|
||||||
// check for external cancellation (timeout, user interrupt)
|
// check for external cancellation (timeout, user interrupt)
|
||||||
|
|
@ -1552,7 +1552,7 @@ namespace seq {
|
||||||
if (node->eval_idx() == m_run_idx) {
|
if (node->eval_idx() == m_run_idx) {
|
||||||
if (node->is_satisfied()) {
|
if (node->is_satisfied()) {
|
||||||
m_sat_node = node;
|
m_sat_node = node;
|
||||||
m_sat_path = m_cur_path;
|
m_sat_path = cur_path;
|
||||||
return search_result::sat;
|
return search_result::sat;
|
||||||
}
|
}
|
||||||
if (node->is_currently_conflict())
|
if (node->is_currently_conflict())
|
||||||
|
|
@ -1562,7 +1562,7 @@ namespace seq {
|
||||||
node->set_eval_idx(m_run_idx);
|
node->set_eval_idx(m_run_idx);
|
||||||
|
|
||||||
// simplify constraints (idempotent after first call)
|
// simplify constraints (idempotent after first call)
|
||||||
const simplify_result sr = node->simplify_and_init();
|
const simplify_result sr = node->simplify_and_init(cur_path);
|
||||||
|
|
||||||
if (sr == simplify_result::conflict) {
|
if (sr == simplify_result::conflict) {
|
||||||
++m_stats.m_num_simplify_conflict;
|
++m_stats.m_num_simplify_conflict;
|
||||||
|
|
@ -1592,7 +1592,7 @@ namespace seq {
|
||||||
|
|
||||||
// integer feasibility check: the solver now holds all path constraints
|
// integer feasibility check: the solver now holds all path constraints
|
||||||
// incrementally; just query the solver directly
|
// incrementally; just query the solver directly
|
||||||
if (!m_cur_path.empty() && !check_int_feasibility(node)) {
|
if (!cur_path.empty() && !check_int_feasibility(node)) {
|
||||||
node->set_reason(backtrack_reason::arithmetic);
|
node->set_reason(backtrack_reason::arithmetic);
|
||||||
++m_stats.m_num_arith_infeasible;
|
++m_stats.m_num_arith_infeasible;
|
||||||
return search_result::unsat;
|
return search_result::unsat;
|
||||||
|
|
@ -1611,7 +1611,7 @@ namespace seq {
|
||||||
return search_result::unsat;
|
return search_result::unsat;
|
||||||
}
|
}
|
||||||
m_sat_node = node;
|
m_sat_node = node;
|
||||||
m_sat_path = m_cur_path;
|
m_sat_path = cur_path;
|
||||||
return search_result::sat;
|
return search_result::sat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1637,7 +1637,7 @@ namespace seq {
|
||||||
// explore children
|
// explore children
|
||||||
bool any_unknown = false;
|
bool any_unknown = false;
|
||||||
for (nielsen_edge *e : node->outgoing()) {
|
for (nielsen_edge *e : node->outgoing()) {
|
||||||
m_cur_path.push_back(e);
|
cur_path.push_back(e);
|
||||||
// Push a solver scope for this edge and assert its side integer
|
// Push a solver scope for this edge and assert its side integer
|
||||||
// constraints. The child's own new constraints will be asserted
|
// constraints. The child's own new constraints will be asserted
|
||||||
// inside the recursive call (above). On return, pop the scope so
|
// inside the recursive call (above). On return, pop the scope so
|
||||||
|
|
@ -1660,7 +1660,7 @@ namespace seq {
|
||||||
// Bump modification counts for the child's context.
|
// Bump modification counts for the child's context.
|
||||||
inc_edge_mod_counts(e);
|
inc_edge_mod_counts(e);
|
||||||
|
|
||||||
const search_result r = search_dfs(e->tgt(), e->is_progress() ? depth : depth + 1);
|
const search_result r = search_dfs(e->tgt(), cur_path);
|
||||||
|
|
||||||
// Restore modification counts on backtrack.
|
// Restore modification counts on backtrack.
|
||||||
dec_edge_mod_counts(e);
|
dec_edge_mod_counts(e);
|
||||||
|
|
@ -1668,7 +1668,7 @@ namespace seq {
|
||||||
m_solver.pop(1);
|
m_solver.pop(1);
|
||||||
if (r == search_result::sat)
|
if (r == search_result::sat)
|
||||||
return search_result::sat;
|
return search_result::sat;
|
||||||
m_cur_path.pop_back();
|
cur_path.pop_back();
|
||||||
if (r == search_result::unknown)
|
if (r == search_result::unknown)
|
||||||
any_unknown = true;
|
any_unknown = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -666,9 +666,9 @@ namespace seq {
|
||||||
void apply_subst(euf::sgraph& sg, nielsen_subst const& s);
|
void apply_subst(euf::sgraph& sg, nielsen_subst const& s);
|
||||||
|
|
||||||
// simplify all constraints at this node and initialize status.
|
// simplify all constraints at this node and initialize status.
|
||||||
// Uses m_graph.m_cur_path for LP solver queries during deterministic power cancellation.
|
// Uses cur_path for LP solver queries during deterministic power cancellation.
|
||||||
// Returns proceed, conflict, satisfied, or restart.
|
// Returns proceed, conflict, satisfied, or restart.
|
||||||
simplify_result simplify_and_init();
|
simplify_result simplify_and_init(ptr_vector<nielsen_edge> const& cur_path);
|
||||||
|
|
||||||
// true if all str_eqs are trivial and there are no str_mems
|
// true if all str_eqs are trivial and there are no str_mems
|
||||||
bool is_satisfied() const;
|
bool is_satisfied() const;
|
||||||
|
|
@ -748,8 +748,7 @@ namespace seq {
|
||||||
ptr_vector<nielsen_edge> m_edges;
|
ptr_vector<nielsen_edge> m_edges;
|
||||||
nielsen_node* m_root = nullptr;
|
nielsen_node* m_root = nullptr;
|
||||||
nielsen_node* m_sat_node = nullptr;
|
nielsen_node* m_sat_node = nullptr;
|
||||||
svector<nielsen_edge*> m_sat_path;
|
ptr_vector<nielsen_edge> m_sat_path;
|
||||||
svector<nielsen_edge*> m_cur_path; // path from root to the current DFS node
|
|
||||||
unsigned m_run_idx = 0;
|
unsigned m_run_idx = 0;
|
||||||
unsigned m_depth_bound = 0;
|
unsigned m_depth_bound = 0;
|
||||||
unsigned m_max_search_depth = 0;
|
unsigned m_max_search_depth = 0;
|
||||||
|
|
@ -852,10 +851,8 @@ namespace seq {
|
||||||
}
|
}
|
||||||
|
|
||||||
// path of edges from root to sat_node (set when sat_node is set)
|
// path of edges from root to sat_node (set when sat_node is set)
|
||||||
svector<nielsen_edge*> const& sat_path() const { return m_sat_path; }
|
ptr_vector<nielsen_edge> const& sat_path() const { return m_sat_path; }
|
||||||
|
|
||||||
// current DFS path (valid during and after solve())
|
|
||||||
svector<nielsen_edge*> const& cur_path() const { return m_cur_path; }
|
|
||||||
|
|
||||||
// add constraints to the root node from external solver
|
// add constraints to the root node from external solver
|
||||||
void add_str_eq(euf::snode* lhs, euf::snode* rhs, smt::enode* l, smt::enode* r);
|
void add_str_eq(euf::snode* lhs, euf::snode* rhs, smt::enode* l, smt::enode* r);
|
||||||
|
|
@ -955,7 +952,7 @@ namespace seq {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
search_result search_dfs(nielsen_node* node, unsigned depth);
|
search_result search_dfs(nielsen_node *node, ptr_vector<nielsen_edge>& path);
|
||||||
|
|
||||||
// Regex widening: overapproximate `str` by replacing variables with
|
// Regex widening: overapproximate `str` by replacing variables with
|
||||||
// the intersection of their primitive regex constraints (or Σ* if
|
// the intersection of their primitive regex constraints (or Σ* if
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ namespace smt {
|
||||||
m_factory = nullptr;
|
m_factory = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void seq_model::extract_assignments(svector<seq::nielsen_edge*> const& sat_path) {
|
void seq_model::extract_assignments(ptr_vector<seq::nielsen_edge> const& sat_path) {
|
||||||
IF_VERBOSE(1, verbose_stream() << "nseq extract_assignments: path length=" << sat_path.size() << "\n";);
|
IF_VERBOSE(1, verbose_stream() << "nseq extract_assignments: path length=" << sat_path.size() << "\n";);
|
||||||
|
|
||||||
// compose substitutions root-to-leaf.
|
// compose substitutions root-to-leaf.
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ namespace smt {
|
||||||
private:
|
private:
|
||||||
// extract variable assignments from the sat path (root-to-leaf edges).
|
// extract variable assignments from the sat path (root-to-leaf edges).
|
||||||
// Composes substitutions along the path to compute final var values.
|
// Composes substitutions along the path to compute final var values.
|
||||||
void extract_assignments(svector<seq::nielsen_edge*> const& sat_path);
|
void extract_assignments(ptr_vector<seq::nielsen_edge> const& sat_path);
|
||||||
|
|
||||||
// recursively substitute known variable assignments into an snode tree.
|
// recursively substitute known variable assignments into an snode tree.
|
||||||
// Returns a concrete Z3 expression.
|
// Returns a concrete Z3 expression.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue