3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-07-23 07:22:33 +00:00

fix loop bug in ho_matching and add throttle configurations

This commit is contained in:
Nikolaj Bjorner 2026-07-07 09:20:14 -07:00
parent d9d3be959c
commit b2f0d0682a
7 changed files with 35 additions and 1 deletions

View file

@ -67,7 +67,15 @@ namespace euf {
void ho_matcher::search() {
IF_VERBOSE(10, display(verbose_stream()));
unsigned budget = m_max_iterations;
while (m.inc()) {
if (budget-- == 0) {
IF_VERBOSE(2, verbose_stream() << "ho_matcher: search budget exhausted\n");
while (!m_backtrack.empty())
backtrack();
break;
}
// Q, B -> Q', B'. Push work on the backtrack stack and new work items
// e, Bw -> Q', B'. Consume backtrack stack
if (!m_goals.empty())
@ -271,6 +279,11 @@ namespace euf {
if (wi.is_done())
return false;
if (wi.level > m_max_depth) {
wi.set_done();
return false;
}
reduce(wi);
auto t = wi.t;
@ -349,6 +362,7 @@ namespace euf {
if (qp->get_decl_sort(i) != qt->get_decl_sort(i))
return false;
m_goals.push(wi.level, wi.term_offset() + td, qp->get_expr(), qt->get_expr());
wi.set_done();
return true;
}

View file

@ -315,6 +315,8 @@ namespace euf {
match_goals m_goals;
unitary_patterns m_unitary;
ptr_vector<match_goal> m_backtrack;
unsigned m_max_depth = 10; // bound on imitation/projection depth (secondary safety cap)
unsigned m_max_iterations = 10000; // per-search expansion-step budget to guarantee termination
mutable array_rewriter m_rewriter;
array_util m_array;
obj_map<app, app*> m_pat2hopat, m_hopat2pat;
@ -386,6 +388,10 @@ namespace euf {
void set_on_match(std::function<void(ho_subst&)>& on_match) { m_on_match = on_match; }
void set_max_depth(unsigned d) { m_max_depth = d; }
void set_max_iterations(unsigned n) { m_max_iterations = n; }
void operator()(expr *pat, expr *t, unsigned num_vars);
void operator()(expr* pat, expr* t, unsigned num_bound, unsigned num_vars);