Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple membership heuristic improvement #145

Merged
merged 6 commits into from
May 22, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
multiple membership heuristic computes inclusion
  • Loading branch information
jurajsic committed May 20, 2024
commit e03ee20381030601840319693a9df0a72e7d0907
62 changes: 62 additions & 0 deletions src/smt/theory_str_noodler/theory_str_noodler_final_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,68 @@ namespace smt::noodler {
}
);

std::vector<app*> list_of_normal_regs;
std::vector<app*> list_of_compl_regs;
for (auto& [is_complement, reg] : list_of_regexes) {
if (is_complement) {
list_of_compl_regs.push_back(reg);
} else {
list_of_normal_regs.push_back(reg);
}
}

std::shared_ptr<mata::nfa::Nfa> intersection = nullptr; // we save the intersected automata here
for (auto& reg : list_of_normal_regs) {
std::shared_ptr<mata::nfa::Nfa> nfa = std::make_shared<mata::nfa::Nfa>(regex::conv_to_nfa(reg, m_util_s, m, alph, false, false));
if (intersection == nullptr) {
intersection = nfa; // this is first nfa
} else {
intersection = std::make_shared<mata::nfa::Nfa>(mata::nfa::reduce(mata::nfa::intersection(*nfa, *intersection)));
}
nfa = nullptr;
if (intersection->is_lang_empty()) {
STRACE("str", tout << "intersection is empty => UNSAT" << std::endl;);
block_curr_len(expr_ref(this->m.mk_false(), this->m));
return l_false;
}
}

if (intersection == nullptr) {
for (auto& reg : list_of_compl_regs) {
std::shared_ptr<mata::nfa::Nfa> nfa = std::make_shared<mata::nfa::Nfa>(regex::conv_to_nfa(reg, m_util_s, m, alph, true, true));
if (intersection == nullptr) {
intersection = nfa; // this is first nfa
} else {
intersection = std::make_shared<mata::nfa::Nfa>(mata::nfa::reduce(mata::nfa::intersection(*nfa, *intersection)));
}
nfa = nullptr;
if (intersection->is_lang_empty()) {
STRACE("str", tout << "intersection is empty => UNSAT" << std::endl;);
block_curr_len(expr_ref(this->m.mk_false(), this->m));
return l_false;
}
}
return l_true;
} else if (!list_of_compl_regs.empty()) {
std::shared_ptr<mata::nfa::Nfa> unionn = nullptr; // we save the unionized automata here
for (auto& reg : list_of_compl_regs) {
std::shared_ptr<mata::nfa::Nfa> nfa = std::make_shared<mata::nfa::Nfa>(regex::conv_to_nfa(reg, m_util_s, m, alph, false, false));
if (unionn == nullptr) {
unionn = nfa; // this is first nfa
} else {
unionn = std::make_shared<mata::nfa::Nfa>(mata::nfa::reduce(mata::nfa::uni(*nfa, *unionn)));
}
}
if (mata::nfa::is_included(*intersection, *unionn)) {
STRACE("str", tout << "inclusion holds => UNSAT" << std::endl;);
block_curr_len(expr_ref(this->m.mk_false(), this->m));
return l_false;
} else {
return l_true;
}
}


std::shared_ptr<mata::nfa::Nfa> intersection = nullptr; // we save the intersected automata here
for (auto& [is_complement, reg] : list_of_regexes) {
STRACE("str", tout << "building intersection for var " << var << " and regex " << mk_pp(reg, m) << (is_complement ? " that needs to be first complemented" : " that does not need to be first complemented") << std::endl;);
Expand Down