summaryrefslogtreecommitdiff
path: root/src/theory/strings
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2021-04-01 17:02:33 -0500
committerGitHub <noreply@github.com>2021-04-01 22:02:33 +0000
commitef2f19f8ba2a72d43586d1f4f364822dbe389aec (patch)
tree24bab218bc3930f360010f537a0be6cbefe0433d /src/theory/strings
parent7fa534c85cbb6eb2863f10840b39501a21acc0b9 (diff)
Simplify caching of regular expression unfolding (#6262)
This ensures that we always cache regular expressions in a user-dependent manner. Previously, we were erroneously caching in a SAT-dependent way for very rare cases when non-constant regular expressions were used. Since we never dependent on current assertions for the unfolding, there is no need to cache in the SAT context. This fixes the second benchmark from #6203. This PR also improves our traces for checking models in strings.
Diffstat (limited to 'src/theory/strings')
-rw-r--r--src/theory/strings/extf_solver.cpp31
-rw-r--r--src/theory/strings/extf_solver.h6
-rw-r--r--src/theory/strings/regexp_solver.cpp16
-rw-r--r--src/theory/strings/theory_strings.cpp13
4 files changed, 43 insertions, 23 deletions
diff --git a/src/theory/strings/extf_solver.cpp b/src/theory/strings/extf_solver.cpp
index 39bcb8f53..fd50e78ee 100644
--- a/src/theory/strings/extf_solver.cpp
+++ b/src/theory/strings/extf_solver.cpp
@@ -85,7 +85,7 @@ bool ExtfSolver::doReduction(int effort, Node n)
if (d_reduced.find(n)!=d_reduced.end())
{
// already sent a reduction lemma
- Trace("strings-extf-debug") << "...skip due to reduced" << std::endl;
+ Trace("strings-extf-debug") << "...skip due to reduced" << std::endl;
return false;
}
// determine the effort level to process the extf at
@@ -157,8 +157,7 @@ bool ExtfSolver::doReduction(int effort, Node n)
}
if (effort != r_effort)
{
-
- Trace("strings-extf-debug") << "...skip due to effort" << std::endl;
+ Trace("strings-extf-debug") << "...skip due to effort" << std::endl;
// not the right effort level to reduce
return false;
}
@@ -722,6 +721,32 @@ bool StringsExtfCallback::getCurrentSubstitution(
return true;
}
+std::string ExtfSolver::debugPrintModel()
+{
+ std::stringstream ss;
+ std::vector<Node> extf;
+ d_extt.getTerms(extf);
+ // each extended function should have at least one annotation below
+ for (const Node& n : extf)
+ {
+ ss << "- " << n;
+ if (!d_extt.isActive(n))
+ {
+ ss << " :extt-inactive";
+ }
+ if (!d_extfInfoTmp[n].d_modelActive)
+ {
+ ss << " :model-inactive";
+ }
+ if (d_reduced.find(n) != d_reduced.end())
+ {
+ ss << " :reduced";
+ }
+ ss << std::endl;
+ }
+ return ss.str();
+}
+
} // namespace strings
} // namespace theory
} // namespace cvc5
diff --git a/src/theory/strings/extf_solver.h b/src/theory/strings/extf_solver.h
index 3cfe2309c..bbc32e7a2 100644
--- a/src/theory/strings/extf_solver.h
+++ b/src/theory/strings/extf_solver.h
@@ -153,6 +153,12 @@ class ExtfSolver
*/
std::vector<Node> getActive(Kind k) const;
//---------------------------------- end information about ExtTheory
+ /**
+ * Print the relevant information regarding why we have a model, return as a
+ * string.
+ */
+ std::string debugPrintModel();
+
private:
/** do reduction
*
diff --git a/src/theory/strings/regexp_solver.cpp b/src/theory/strings/regexp_solver.cpp
index 2d4404c10..7737a90f7 100644
--- a/src/theory/strings/regexp_solver.cpp
+++ b/src/theory/strings/regexp_solver.cpp
@@ -96,7 +96,6 @@ void RegExpSolver::check(const std::map<Node, std::vector<Node> >& mems)
bool addedLemma = false;
bool changed = false;
std::vector<Node> processed;
- std::vector<Node> cprocessed;
Trace("regexp-process") << "Checking Memberships ... " << std::endl;
for (const std::pair<const Node, std::vector<Node> >& mr : mems)
@@ -287,14 +286,7 @@ void RegExpSolver::check(const std::map<Node, std::vector<Node> >& mems)
polarity ? InferenceId::STRINGS_RE_UNFOLD_POS : InferenceId::STRINGS_RE_UNFOLD_NEG;
d_im.sendInference(iexp, noExplain, conc, inf);
addedLemma = true;
- if (changed)
- {
- cprocessed.push_back(assertion);
- }
- else
- {
- processed.push_back(assertion);
- }
+ processed.push_back(assertion);
if (e == 0)
{
// Remember that we have unfolded a membership for x
@@ -326,12 +318,6 @@ void RegExpSolver::check(const std::map<Node, std::vector<Node> >& mems)
<< "...add " << processed[i] << " to u-cache." << std::endl;
d_regexp_ucached.insert(processed[i]);
}
- for (unsigned i = 0; i < cprocessed.size(); i++)
- {
- Trace("strings-regexp")
- << "...add " << cprocessed[i] << " to c-cache." << std::endl;
- d_regexp_ccached.insert(cprocessed[i]);
- }
}
}
}
diff --git a/src/theory/strings/theory_strings.cpp b/src/theory/strings/theory_strings.cpp
index 5bd92267e..f2f584da7 100644
--- a/src/theory/strings/theory_strings.cpp
+++ b/src/theory/strings/theory_strings.cpp
@@ -203,13 +203,16 @@ void TheoryStrings::presolve() {
bool TheoryStrings::collectModelValues(TheoryModel* m,
const std::set<Node>& termSet)
{
- if (Trace.isOn("strings-model"))
+ if (Trace.isOn("strings-debug-model"))
{
- Trace("strings-model") << "TheoryStrings : Collect model values"
- << std::endl;
- Trace("strings-model") << "Equivalence classes are:" << std::endl;
- Trace("strings-model") << debugPrintStringsEqc() << std::endl;
+ Trace("strings-debug-model")
+ << "TheoryStrings::collectModelValues" << std::endl;
+ Trace("strings-debug-model") << "Equivalence classes are:" << std::endl;
+ Trace("strings-debug-model") << debugPrintStringsEqc() << std::endl;
+ Trace("strings-debug-model") << "Extended functions are:" << std::endl;
+ Trace("strings-debug-model") << d_esolver.debugPrintModel() << std::endl;
}
+ Trace("strings-model") << "TheoryStrings::collectModelValues" << std::endl;
std::map<TypeNode, std::unordered_set<Node, NodeHashFunction> > repSet;
// Generate model
// get the relevant string equivalence classes
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback