diff options
author | Andrew Reynolds <andrew.j.reynolds@gmail.com> | 2021-01-28 14:01:26 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-28 14:01:26 -0600 |
commit | e234ff58f561ac97642df15c698962faa9d1e5e4 (patch) | |
tree | cfac18adaeb0fccc348b81e84c854400d38a01fe /src/prop/prop_engine.cpp | |
parent | 3234db430074e278258e6d687c07146a59769a92 (diff) |
Simplify lemma interface (#5819)
This makes it so that TheoryEngine::lemma returns void not LemmaStatus.
Currently, there was only one use of LemmaStatus by theory solvers, which was CEGQI using it as a way of getting the preprocessed form of a lemma. This makes it so that there is an explicit method in Valuation for getting the preprocessed form of a term + its skolems and their definition assertions.
It also simplifies a few things, e.g. Valuation calls are forwarded to PropEngine instead of going through TheoryEngine. It fixes a few issues in TermFormulaRemoval related to getSkolems.
Diffstat (limited to 'src/prop/prop_engine.cpp')
-rw-r--r-- | src/prop/prop_engine.cpp | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/src/prop/prop_engine.cpp b/src/prop/prop_engine.cpp index fb43ebe73..28159c229 100644 --- a/src/prop/prop_engine.cpp +++ b/src/prop/prop_engine.cpp @@ -36,6 +36,7 @@ #include "prop/theory_proxy.h" #include "smt/smt_statistics_registry.h" #include "theory/output_channel.h" +#include "theory/rewriter.h" #include "theory/theory_engine.h" #include "util/resource_manager.h" #include "util/result.h" @@ -206,7 +207,7 @@ void PropEngine::assertFormula(TNode node) { } } -Node PropEngine::assertLemma(theory::TrustNode tlemma, theory::LemmaProperty p) +void PropEngine::assertLemma(theory::TrustNode tlemma, theory::LemmaProperty p) { bool removable = isLemmaPropertyRemovable(p); @@ -261,20 +262,6 @@ Node PropEngine::assertLemma(theory::TrustNode tlemma, theory::LemmaProperty p) } d_decisionEngine->addAssertions(assertions, ppLemmasF, ppSkolems); } - - // make the return lemma, which the theory engine will use - Node retLemma = tplemma.getProven(); - if (!ppLemmas.empty()) - { - std::vector<Node> lemmas{retLemma}; - for (const theory::TrustNode& tnl : ppLemmas) - { - lemmas.push_back(tnl.getProven()); - } - // the returned lemma is the conjunction of all additional lemmas. - retLemma = NodeManager::currentNM()->mkNode(kind::AND, lemmas); - } - return retLemma; } void PropEngine::assertLemmaInternal(theory::TrustNode trn, bool removable) @@ -441,6 +428,7 @@ Node PropEngine::ensureLiteral(TNode n) Node PropEngine::getPreprocessedTerm(TNode n) { + Node rewritten = theory::Rewriter::rewrite(n); // must preprocess std::vector<theory::TrustNode> newLemmas; std::vector<Node> newSkolems; @@ -453,6 +441,39 @@ Node PropEngine::getPreprocessedTerm(TNode n) return tpn.isNull() ? Node(n) : tpn.getNode(); } +Node PropEngine::getPreprocessedTerm(TNode n, + std::vector<Node>& skAsserts, + std::vector<Node>& sks) +{ + // get the preprocessed form of the term + Node pn = getPreprocessedTerm(n); + // initialize the set of skolems and assertions to process + std::vector<theory::TrustNode> toProcessAsserts; + std::vector<Node> toProcess; + d_theoryProxy->getSkolems(pn, toProcessAsserts, toProcess); + size_t index = 0; + // until fixed point is reached + while (index < toProcess.size()) + { + theory::TrustNode ka = toProcessAsserts[index]; + Node k = toProcess[index]; + index++; + if (std::find(sks.begin(), sks.end(), k) != sks.end()) + { + // already added the skolem to the list + continue; + } + // must preprocess lemmas as well + Node kap = getPreprocessedTerm(ka.getProven()); + skAsserts.push_back(kap); + sks.push_back(k); + // get the skolems in the preprocessed form of the lemma ka + d_theoryProxy->getSkolems(kap, toProcessAsserts, toProcess); + } + // return the preprocessed term + return pn; +} + void PropEngine::push() { Assert(!d_inCheckSat) << "Sat solver in solve()!"; |