mirror of
https://github.com/Z3Prover/z3
synced 2026-05-30 21:57:46 +00:00
Fixed regex factorization again
This commit is contained in:
parent
adb9ca4305
commit
5b3d734ecb
6 changed files with 28 additions and 25 deletions
|
|
@ -3281,7 +3281,7 @@ namespace seq {
|
|||
}
|
||||
|
||||
bool nielsen_graph::apply_regex_factorization(nielsen_node* node) {
|
||||
if (!m_regex_factorization)
|
||||
if (m_regex_factorization_threshold == 0)
|
||||
return false;
|
||||
|
||||
struct rf_split {
|
||||
|
|
@ -3328,6 +3328,8 @@ namespace seq {
|
|||
}
|
||||
|
||||
feasible.push_back({ sn_p, sn_q, m_dep_mgr.mk_join(mem.m_dep, first_filter_dep) });
|
||||
if (feasible.size() > m_regex_factorization_threshold)
|
||||
break;
|
||||
}
|
||||
|
||||
if (feasible.empty()) {
|
||||
|
|
@ -3336,25 +3338,26 @@ namespace seq {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (feasible.size() > 1)
|
||||
if (feasible.size() > m_regex_factorization_threshold)
|
||||
continue;
|
||||
|
||||
nielsen_node* child = mk_child(node);
|
||||
mk_edge(node, child, true);
|
||||
|
||||
// remove the original mem from child
|
||||
auto& child_mems = child->str_mems();
|
||||
for (unsigned k = 0; k < child_mems.size(); ++k) {
|
||||
if (child_mems[k] == mem) {
|
||||
child_mems[k] = child_mems.back();
|
||||
child_mems.pop_back();
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (auto& [m_p, m_q, m_dep] : feasible) {
|
||||
nielsen_node* child = mk_child(node);
|
||||
mk_edge(node, child, true);
|
||||
|
||||
child->add_str_mem(str_mem(first, feasible[0].m_p, feasible[0].m_dep));
|
||||
child->add_str_mem(str_mem(tail, feasible[0].m_q, feasible[0].m_dep));
|
||||
|
||||
// remove the original mem from child
|
||||
auto& child_mems = child->str_mems();
|
||||
for (unsigned k = 0; k < child_mems.size(); ++k) {
|
||||
if (child_mems[k] == mem) {
|
||||
child_mems[k] = child_mems.back();
|
||||
child_mems.pop_back();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
child->add_str_mem(str_mem(first, m_p, m_dep));
|
||||
child->add_str_mem(str_mem(tail, m_q, m_dep));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -839,7 +839,7 @@ namespace seq {
|
|||
unsigned m_max_nodes = 0; // 0 = unlimited
|
||||
bool m_parikh_enabled = true;
|
||||
bool m_signature_split = false;
|
||||
bool m_regex_factorization = true;
|
||||
unsigned m_regex_factorization_threshold = 1;
|
||||
unsigned m_fresh_cnt = 0;
|
||||
nielsen_stats m_stats;
|
||||
|
||||
|
|
@ -968,7 +968,7 @@ namespace seq {
|
|||
|
||||
void set_signature_split(bool e) { m_signature_split = e; }
|
||||
|
||||
void set_regex_factorization(bool e) { m_regex_factorization = e; }
|
||||
void set_regex_factorization_threshold(unsigned max) { m_regex_factorization_threshold = max; }
|
||||
|
||||
// display for debugging
|
||||
std::ostream& display(std::ostream& out) const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue