This sets up the preprocessing pass context in preparation for proof production.
This PR makes the top level substitutions map into a TrustSubstitutionMap, the data structure that applies substitutions in a way that tracks proofs.
This PR also makes the "apply subst" preprocessing pass proof producing.
}
void AssertionPipeline::replaceTrusted(size_t i, theory::TrustNode trn)
-{
+{
+ if (trn.isNull())
+ {
+ // null trust node denotes no change, nothing to do
+ return;
+ }
Assert(trn.getKind() == theory::TrustNodeKind::REWRITE);
replace(i, trn.getNode(), trn.getGenerator());
}
// TODO(#1255): Substitutions in incremental mode should be managed with a
// proper data structure.
- theory::SubstitutionMap& substMap =
+ theory::TrustSubstitutionMap& tlsm =
d_preprocContext->getTopLevelSubstitutions();
unsigned size = assertionsToPreprocess->size();
for (unsigned i = 0; i < size; ++i)
<< std::endl;
d_preprocContext->spendResource(
ResourceManager::Resource::PreprocessStep);
- assertionsToPreprocess->replace(i,
- theory::Rewriter::rewrite(substMap.apply(
- (*assertionsToPreprocess)[i])));
+ assertionsToPreprocess->replaceTrusted(
+ i, tlsm.apply((*assertionsToPreprocess)[i]));
Trace("apply-substs") << " got " << (*assertionsToPreprocess)[i]
<< std::endl;
}
propagator->getBackEdges();
unordered_set<unsigned long> removeAssertions;
- SubstitutionMap& top_level_substs =
+ theory::TrustSubstitutionMap& tlsm =
d_preprocContext->getTopLevelSubstitutions();
+ SubstitutionMap& top_level_substs = tlsm.get();
NodeManager* nm = NodeManager::currentNM();
Node zero = nm->mkConst(Rational(0)), one = nm->mkConst(Rational(1));
<< "Iterate through " << propagator->getLearnedLiterals().size()
<< " learned literals." << std::endl;
// No conflict, go through the literals and solve them
- SubstitutionMap& top_level_substs =
- d_preprocContext->getTopLevelSubstitutions();
+ TrustSubstitutionMap& ttls = d_preprocContext->getTopLevelSubstitutions();
+ CVC4_UNUSED SubstitutionMap& top_level_substs = ttls.get();
SubstitutionMap constantPropagations(d_preprocContext->getUserContext());
TrustSubstitutionMap tnewSubstituions(d_preprocContext->getUserContext(),
nullptr);
** The preprocessing pass context for passes.
**/
-#include "preprocessing_pass_context.h"
+#include "preprocessing/preprocessing_pass_context.h"
#include "expr/node_algorithm.h"
PreprocessingPassContext::PreprocessingPassContext(
SmtEngine* smt,
RemoveTermFormulas* iteRemover,
- theory::booleans::CircuitPropagator* circuitPropagator)
+ theory::booleans::CircuitPropagator* circuitPropagator,
+ ProofNodeManager* pnm)
: d_smt(smt),
d_resourceManager(smt->getResourceManager()),
d_iteRemover(iteRemover),
- d_topLevelSubstitutions(smt->getUserContext()),
+ d_topLevelSubstitutions(smt->getUserContext(), pnm),
d_circuitPropagator(circuitPropagator),
+ d_pnm(pnm),
d_symsInAssertions(smt->getUserContext())
{
}
req.widenLogic(id);
}
+theory::TrustSubstitutionMap&
+PreprocessingPassContext::getTopLevelSubstitutions()
+{
+ return d_topLevelSubstitutions;
+}
+
void PreprocessingPassContext::enableIntegers()
{
LogicRequest req(*d_smt);
}
}
+ProofNodeManager* PreprocessingPassContext::getProofNodeManager()
+{
+ return d_pnm;
+}
+
} // namespace preprocessing
} // namespace CVC4
#include "smt/term_formula_removal.h"
#include "theory/booleans/circuit_propagator.h"
#include "theory/theory_engine.h"
+#include "theory/trust_substitutions.h"
#include "util/resource_manager.h"
namespace CVC4 {
PreprocessingPassContext(
SmtEngine* smt,
RemoveTermFormulas* iteRemover,
- theory::booleans::CircuitPropagator* circuitPropagator);
+ theory::booleans::CircuitPropagator* circuitPropagator,
+ ProofNodeManager* pnm);
SmtEngine* getSmt() { return d_smt; }
TheoryEngine* getTheoryEngine() { return d_smt->getTheoryEngine(); }
void widenLogic(theory::TheoryId id);
/** Gets a reference to the top-level substitution map */
- theory::SubstitutionMap& getTopLevelSubstitutions()
- {
- return d_topLevelSubstitutions;
- }
+ theory::TrustSubstitutionMap& getTopLevelSubstitutions();
/* Enable Integers. */
void enableIntegers();
*/
void recordSymbolsInAssertions(const std::vector<Node>& assertions);
+ /** The the proof node manager associated with this context, if it exists */
+ ProofNodeManager* getProofNodeManager();
+
private:
/** Pointer to the SmtEngine that this context was created in. */
SmtEngine* d_smt;
RemoveTermFormulas* d_iteRemover;
/* The top level substitutions */
- theory::SubstitutionMap d_topLevelSubstitutions;
+ theory::TrustSubstitutionMap d_topLevelSubstitutions;
/** Instance of the circuit propagator */
theory::booleans::CircuitPropagator* d_circuitPropagator;
+ /** Pointer to the proof node manager, if it exists */
+ ProofNodeManager* d_pnm;
/**
* The (user-context-dependent) set of symbols that occur in at least one
Preprocessor::Preprocessor(SmtEngine& smt,
context::UserContext* u,
AbstractValues& abs)
- : d_smt(smt),
+ : d_context(u),
+ d_smt(smt),
d_absValues(abs),
d_propagator(true, true),
d_assertionsProcessed(u, false),
d_processor(smt, *smt.getResourceManager()),
- d_rtf(u)
+ d_rtf(u),
+ d_pnm(nullptr)
{
}
void Preprocessor::finishInit()
{
d_ppContext.reset(new preprocessing::PreprocessingPassContext(
- &d_smt, &d_rtf, &d_propagator));
+ &d_smt, &d_rtf, &d_propagator, d_pnm));
// initialize the preprocessing passes
d_processor.finishInit(d_ppContext.get());
preprocessing::AssertionPipeline& ap = as.getAssertionPipeline();
// should not be called if empty
- Assert(ap.size() != 0) << "Can only preprocess a non-empty list of assertions";
+ Assert(ap.size() != 0)
+ << "Can only preprocess a non-empty list of assertions";
if (d_assertionsProcessed && options::incrementalSolving())
{
}
std::unordered_map<Node, Node, NodeHashFunction> cache;
Node n = d_processor.expandDefinitions(nas, cache);
- Node ns = applySubstitutions(n);
+ TrustNode ts = d_ppContext->getTopLevelSubstitutions().apply(n);
+ Node ns = ts.isNull() ? n : ts.getNode();
if (removeItes)
{
// also remove ites if asked
return ns;
}
-Node Preprocessor::applySubstitutions(TNode node)
+void Preprocessor::setProofGenerator(PreprocessProofGenerator* pppg)
{
- return Rewriter::rewrite(d_ppContext->getTopLevelSubstitutions().apply(node));
+ Assert(pppg != nullptr);
+ d_pnm = pppg->getManager();
+ d_rtf.setProofNodeManager(d_pnm);
}
} // namespace smt
*/
RemoveTermFormulas& getTermFormulaRemover();
- private:
/**
- * Apply substitutions that have been inferred by preprocessing, return the
- * substituted form of node.
+ * Set proof node manager. Enables proofs in this preprocessor.
*/
- Node applySubstitutions(TNode node);
+ void setProofGenerator(PreprocessProofGenerator* pppg);
+
+ private:
+ /** A copy of the current context */
+ context::Context* d_context;
/** Reference to the parent SmtEngine */
SmtEngine& d_smt;
/** Reference to the abstract values utility */
* in term contexts.
*/
RemoveTermFormulas d_rtf;
+ /** Proof node manager */
+ ProofNodeManager* d_pnm;
};
} // namespace smt
return true;
}
- SubstitutionMap& top_level_substs =
- d_preprocessingPassContext->getTopLevelSubstitutions();
-
if (options::bvGaussElim())
{
d_passes["bv-gauss"]->apply(&assertions);
// First, find all skolems that appear in the substitution map - their
// associated iteExpr will need to be moved to the main assertion set
set<TNode> skolemSet;
+ SubstitutionMap& top_level_substs =
+ d_preprocessingPassContext->getTopLevelSubstitutions().get();
SubstitutionMap::iterator pos = top_level_substs.begin();
for (; pos != top_level_substs.end(); ++pos)
{
if (options::proofNew())
{
d_pfManager.reset(new PfManager(getUserContext(), this));
+ PreprocessProofGenerator* pppg = d_pfManager->getPreprocessProofGenerator();
// use this proof node manager
pnm = d_pfManager->getProofNodeManager();
// enable proof support in the rewriter
d_rewriter->setProofNodeManager(pnm);
// enable it in the assertions pipeline
- d_asserts->setProofGenerator(d_pfManager->getPreprocessProofGenerator());
+ d_asserts->setProofGenerator(pppg);
// enable it in the SmtSolver
d_smtSolver->setProofNodeManager(pnm);
+ // enabled proofs in the preprocessor
+ d_pp->setProofGenerator(pppg);
}
Trace("smt-debug") << "SmtEngine::finishInit" << std::endl;