d_propagatedLiterals(context),
d_propagatedLiteralsIndex(context, 0),
d_atomRequests(context),
- d_tpp(*this, iteRemover, d_pnm),
+ d_tpp(*this, iteRemover, userContext, d_pnm),
d_combineTheoriesTime("TheoryEngine::combineTheoriesTime"),
d_true(),
d_false(),
theoryOf(theoryId)->shutdown();
}
}
-
- d_tpp.clearCache();
}
theory::Theory::PPAssertStatus TheoryEngine::solve(
return solveStatus;
}
-void TheoryEngine::preprocessStart() { d_tpp.clearCache(); }
-
-Node TheoryEngine::preprocess(TNode assertion)
+TrustNode TheoryEngine::preprocess(TNode assertion)
{
- TrustNode trn = d_tpp.theoryPreprocess(assertion);
- if (trn.isNull())
- {
- // no change
- return assertion;
- }
- // notice that we could alternatively return the trust node here.
- return trn.getNode();
+ return d_tpp.theoryPreprocess(assertion);
}
void TheoryEngine::notifyPreprocessedAssertions(
Debug("ensureLiteral") << "rewriting: " << n << std::endl;
Node rewritten = Rewriter::rewrite(n);
Debug("ensureLiteral") << " got: " << rewritten << std::endl;
- Node preprocessed = preprocess(rewritten);
+ TrustNode tp = preprocess(rewritten);
+ Node preprocessed = tp.isNull() ? rewritten : tp.getNode();
Debug("ensureLiteral") << "preprocessed: " << preprocessed << std::endl;
d_propEngine->ensureLiteral(preprocessed);
return preprocessed;
TheoryPreprocessor::TheoryPreprocessor(TheoryEngine& engine,
RemoveTermFormulas& tfr,
+ context::UserContext* userContext,
ProofNodeManager* pnm)
: d_engine(engine),
d_logicInfo(engine.getLogicInfo()),
- d_ppCache(),
+ d_ppCache(userContext),
d_tfr(tfr),
- d_pfContext(),
d_tpg(pnm ? new TConvProofGenerator(
pnm,
- &d_pfContext,
+ userContext,
TConvPolicy::FIXPOINT,
TConvCachePolicy::NEVER,
"TheoryPreprocessor::preprocess_rewrite",
: nullptr),
d_tspg(nullptr),
d_tpgRew(pnm ? new TConvProofGenerator(pnm,
- &d_pfContext,
+ userContext,
TConvPolicy::FIXPOINT,
TConvCachePolicy::NEVER,
"TheoryPreprocessor::rewrite")
d_tspgNoPp(nullptr),
d_lp(pnm ? new LazyCDProof(pnm,
nullptr,
- &d_pfContext,
+ userContext,
"TheoryPreprocessor::LazyCDProof")
: nullptr)
{
if (isProofEnabled())
{
- // push the proof context, since proof steps may be cleared on calls to
- // clearCache() below.
- d_pfContext.push();
// Make the main term conversion sequence generator, which tracks up to
// three conversions made in succession:
// (1) theory preprocessing+rewriting
ts.push_back(d_tfr.getTConvProofGenerator());
ts.push_back(d_tpg.get());
d_tspg.reset(new TConvSeqProofGenerator(
- pnm, ts, &d_pfContext, "TheoryPreprocessor::sequence"));
+ pnm, ts, userContext, "TheoryPreprocessor::sequence"));
// Make the "no preprocess" term conversion sequence generator, which
// applies only steps (2) and (3), where notice (3) must use the
// "pure rewrite" term conversion (d_tpgRew).
tsNoPp.push_back(d_tfr.getTConvProofGenerator());
tsNoPp.push_back(d_tpgRew.get());
d_tspgNoPp.reset(new TConvSeqProofGenerator(
- pnm, tsNoPp, &d_pfContext, "TheoryPreprocessor::sequence_no_pp"));
+ pnm, tsNoPp, userContext, "TheoryPreprocessor::sequence_no_pp"));
}
}
TheoryPreprocessor::~TheoryPreprocessor() {}
-void TheoryPreprocessor::clearCache()
-{
- Trace("tpp-proof-debug") << "TheoryPreprocessor::clearCache" << std::endl;
- d_ppCache.clear();
- // clear proofs from d_tpg, d_tspg and d_lp using internal push/pop context
- if (isProofEnabled())
- {
- d_pfContext.pop();
- d_pfContext.push();
- }
-}
-
TrustNode TheoryPreprocessor::preprocess(TNode node,
std::vector<TrustNode>& newLemmas,
std::vector<Node>& newSkolems,
TrustNode tpp = theoryPreprocess(node);
ppNode = tpp.getNode();
}
- Trace("tpp-proof-debug")
- << "TheoryPreprocessor::preprocess: after preprocessing " << ppNode
- << std::endl;
// Remove the ITEs
- Trace("te-tform-rm") << "Remove term formulas from " << ppNode << std::endl;
TrustNode ttfr = d_tfr.run(ppNode, newLemmas, newSkolems, false);
- Trace("te-tform-rm") << "..done " << ttfr.getNode() << std::endl;
Node rtfNode = ttfr.getNode();
- Trace("tpp-proof-debug")
- << "TheoryPreprocessor::preprocess: rtf returned node " << rtfNode
- << std::endl;
if (Debug.isOn("lemma-ites"))
{
// Rewrite the main node, we rewrite and store the proof step, if necessary,
// in d_tpg, which maintains the fact that d_tpg can prove the rewrite.
Node retNode = rewriteWithProof(rtfNode);
- Trace("tpp-proof-debug")
- << "TheoryPreprocessor::preprocess: after rewriting is " << retNode
- << std::endl;
+
+ if (Trace.isOn("tpp-proof-debug"))
+ {
+ if (node != ppNode)
+ {
+ Trace("tpp-proof-debug")
+ << "after preprocessing : " << ppNode << std::endl;
+ }
+ if (rtfNode != ppNode)
+ {
+ Trace("tpp-proof-debug") << "after rtf : " << rtfNode << std::endl;
+ }
+ if (retNode != rtfNode)
+ {
+ Trace("tpp-proof-debug") << "after rewriting : " << retNode << std::endl;
+ }
+ Trace("tpp-proof-debug")
+ << "TheoryPreprocessor::preprocess: finish" << std::endl;
+ }
if (node == retNode)
{
// no change
{
Node ppRewritten = ppTheoryRewrite(current);
d_ppCache[current] = ppRewritten;
- Assert(Rewriter::rewrite(d_ppCache[current]) == d_ppCache[current]);
+ Assert(Rewriter::rewrite(d_ppCache[current].get())
+ == d_ppCache[current].get());
continue;
}
for (unsigned i = 0; i < current.getNumChildren(); ++i)
{
Assert(d_ppCache.find(current[i]) != d_ppCache.end());
- builder << d_ppCache[current[i]];
+ builder << d_ppCache[current[i]].get();
}
// Mark the substitution and continue
Node result = builder;
#include <unordered_map>
+#include "context/cdhashmap.h"
+#include "context/context.h"
#include "expr/lazy_proof.h"
#include "expr/node.h"
#include "expr/tconv_seq_proof_generator.h"
*/
class TheoryPreprocessor
{
- typedef std::unordered_map<Node, Node, NodeHashFunction> NodeMap;
+ typedef context::CDHashMap<Node, Node, NodeHashFunction> NodeMap;
public:
/** Constructs a theory preprocessor */
TheoryPreprocessor(TheoryEngine& engine,
RemoveTermFormulas& tfr,
+ context::UserContext* userContext,
ProofNodeManager* pnm = nullptr);
/** Destroys a theory preprocessor */
~TheoryPreprocessor();
- /** Clear the cache of this class */
- void clearCache();
/**
* Preprocesses the given assertion node. It returns a TrustNode of kind
* TrustNodeKind::REWRITE indicating the preprocessed form of node. It stores
NodeMap d_ppCache;
/** The term formula remover */
RemoveTermFormulas& d_tfr;
- /** The context for the proof generator below */
- context::Context d_pfContext;
/** The term context, which computes hash values for term contexts. */
InQuantTermContext d_iqtc;
/**