Refactor how assertions are added to decision engine (#2396)
authorAndres Noetzli <andres.noetzli@gmail.com>
Sat, 15 Sep 2018 05:15:37 +0000 (22:15 -0700)
committerGitHub <noreply@github.com>
Sat, 15 Sep 2018 05:15:37 +0000 (22:15 -0700)
Before refactoring the preprocessing passes, we were using three
arguments to add assertions to the decision engine. Now all that
information lives in the AssertionPipeline. This commit moves the
AssertionPipeline to its own file and changes the `addAssertions()`
methods related to the decision engine to take an AssertionPipeline as
an arguement instead of three separate ones. Additionally, the
TheoryEngine now uses an AssertionPipeline for lemmas.

23 files changed:
src/Makefile.am
src/api/cvc4cpp.cpp
src/decision/decision_engine.cpp
src/decision/decision_engine.h
src/decision/decision_strategy.h
src/decision/justification_heuristic.cpp
src/decision/justification_heuristic.h
src/include/cvc4_private_library.h
src/preprocessing/assertion_pipeline.cpp [new file with mode: 0644]
src/preprocessing/assertion_pipeline.h [new file with mode: 0644]
src/preprocessing/passes/apply_substs.cpp
src/preprocessing/passes/miplib_trick.cpp
src/preprocessing/passes/non_clausal_simp.cpp
src/preprocessing/preprocessing_pass.cpp
src/preprocessing/preprocessing_pass.h
src/preprocessing/preprocessing_pass_context.cpp
src/preprocessing/preprocessing_pass_context.h
src/smt/smt_engine.cpp
src/theory/quantifiers/cegqi/inst_strategy_cbqi.cpp
src/theory/quantifiers/quant_conflict_find.cpp
src/theory/quantifiers/sygus/sygus_repair_const.cpp
src/theory/theory_engine.cpp
test/unit/preprocessing/pass_bv_gauss_white.h

index e2109cf1ea42f1ed56509582b43cc60c1e5cd038..caad72fd5e0c401043f68ed90c7c8493ab3378de 100644 (file)
@@ -61,6 +61,8 @@ libcvc4_la_SOURCES = \
        decision/decision_strategy.h \
        decision/justification_heuristic.cpp \
        decision/justification_heuristic.h \
+       preprocessing/assertion_pipeline.cpp \
+       preprocessing/assertion_pipeline.h \
        preprocessing/passes/apply_substs.cpp \
        preprocessing/passes/apply_substs.h \
        preprocessing/passes/apply_to_const.cpp \
@@ -97,10 +99,10 @@ libcvc4_la_SOURCES = \
        preprocessing/passes/pseudo_boolean_processor.h \
        preprocessing/passes/miplib_trick.cpp \
        preprocessing/passes/miplib_trick.h \
-       preprocessing/passes/quantifiers_preprocess.cpp \
-       preprocessing/passes/quantifiers_preprocess.h \
        preprocessing/passes/quantifier_macros.cpp \
        preprocessing/passes/quantifier_macros.h \
+       preprocessing/passes/quantifiers_preprocess.cpp \
+       preprocessing/passes/quantifiers_preprocess.h \
        preprocessing/passes/real_to_int.cpp \
        preprocessing/passes/real_to_int.h \
        preprocessing/passes/rewrite.cpp \
index 8aed4fb32ebc8392bef96bf676e2d884e3605a4b..013e2165fcbc08b515e45f327c15af72456a49f0 100644 (file)
@@ -610,10 +610,7 @@ const static std::unordered_map<CVC4::Kind, Kind, CVC4::kind::KindHashFunction>
 
 namespace {
 
-bool isDefinedKind(Kind k)
-{
-  return k > UNDEFINED_KIND && k < LAST_KIND;
-}
+bool isDefinedKind(Kind k) { return k > UNDEFINED_KIND && k < LAST_KIND; }
 
 bool isDefinedIntKind(CVC4::Kind k)
 {
index 8e419e768d1fcc92e13130b0ea9f1a2a015b02e8..01f78f2d6f938cdce7797228cb6593482cbecc6b 100644 (file)
@@ -98,31 +98,21 @@ SatValue DecisionEngine::getPolarity(SatVariable var)
   }
 }
 
-void DecisionEngine::addAssertions(const vector<Node> &assertions)
-{
-  Assert(false);  // doing this so that we revisit what to do
-                  // here. Currently not being used.
-
-  // d_result = SAT_VALUE_UNKNOWN;
-  // d_assertions.reserve(assertions.size());
-  // for(unsigned i = 0; i < assertions.size(); ++i)
-  //   d_assertions.push_back(assertions[i]);
-}
-
-void DecisionEngine::addAssertions(const vector<Node> &assertions,
-                                   unsigned assertionsEnd,
-                                   IteSkolemMap iteSkolemMap)
+void DecisionEngine::addAssertions(
+    const preprocessing::AssertionPipeline& assertions)
 {
   // new assertions, reset whatever result we knew
   d_result = SAT_VALUE_UNKNOWN;
 
-  // d_assertions.reserve(assertions.size());
-  for(unsigned i = 0; i < assertions.size(); ++i)
-    d_assertions.push_back(assertions[i]);
+  for (const Node& assertion : assertions)
+  {
+    d_assertions.push_back(assertion);
+  }
 
   for(unsigned i = 0; i < d_needIteSkolemMap.size(); ++i)
-    d_needIteSkolemMap[i]->
-      addAssertions(assertions, assertionsEnd, iteSkolemMap);
+  {
+    d_needIteSkolemMap[i]->addAssertions(assertions);
+  }
 }
 
 }/* CVC4 namespace */
index 838e53b5a19ffa6ae13b4673a301a72030d33fc9..c5325bc9a125a1846cd08b9e55bd8fde18f358c6 100644 (file)
 #include "base/output.h"
 #include "decision/decision_strategy.h"
 #include "expr/node.h"
+#include "preprocessing/assertion_pipeline.h"
 #include "prop/cnf_stream.h"
 #include "prop/prop_engine.h"
 #include "prop/sat_solver_types.h"
-#include "smt/term_formula_removal.h"
 #include "smt/smt_engine_scope.h"
+#include "smt/term_formula_removal.h"
 
 using namespace std;
 using namespace CVC4::prop;
@@ -173,21 +174,10 @@ public:
   /*   return d_needIteSkolemMap.size() > 0; */
   /* } */
 
-  /* add a set of assertions */
-  void addAssertions(const vector<Node> &assertions);
-
   /**
-   * add a set of assertions, while providing a mapping between skolem
-   * variables and corresponding assertions. It is assumed that all
-   * assertions after assertionEnd were generated by ite
-   * removal. Hence, iteSkolemMap maps into only these.
+   * Add a list of assertions from an AssertionPipeline.
    */
-  void addAssertions(const vector<Node> &assertions,
-                     unsigned assertionsEnd,
-                     IteSkolemMap iteSkolemMap);
-
-  /* add a single assertion */
-  void addAssertion(Node n);
+  void addAssertions(const preprocessing::AssertionPipeline& assertions);
 
   // Interface for Strategies to use stuff stored in Decision Engine
   // (which was possibly requested by them on initialization)
index bad80d4efc1415dad60dc79d074158ccd6780e78..d26b28eebd3fe9127348b0ddf66da6f4c73076d3 100644 (file)
@@ -19,6 +19,7 @@
 #ifndef __CVC4__DECISION__DECISION_STRATEGY_H
 #define __CVC4__DECISION__DECISION_STRATEGY_H
 
+#include "preprocessing/assertion_pipeline.h"
 #include "prop/sat_solver_types.h"
 #include "smt/term_formula_removal.h"
 
@@ -57,9 +58,8 @@ public:
 
   bool needIteSkolemMap() override { return true; }
 
-  virtual void addAssertions(const std::vector<Node> &assertions,
-                             unsigned assertionsEnd,
-                             IteSkolemMap iteSkolemMap) = 0;
+  virtual void addAssertions(
+      const preprocessing::AssertionPipeline& assertions) = 0;
 };/* class ITEDecisionStrategy */
 
 class RelevancyStrategy : public ITEDecisionStrategy {
index 7d19d3363d949e642185c578441b015595c1f424..b4fbe1cbdc6da18188cbf208b0e665c365a7a413 100644 (file)
@@ -163,12 +163,10 @@ inline void computeXorIffDesiredValues
   }
 }
 
-
-
-void JustificationHeuristic::addAssertions
-(const std::vector<Node> &assertions,
- unsigned assertionsEnd,
- IteSkolemMap iteSkolemMap) {
+void JustificationHeuristic::addAssertions(
+    const preprocessing::AssertionPipeline &assertions)
+{
+  size_t assertionsEnd = assertions.getRealAssertionsEnd();
 
   Trace("decision")
     << "JustificationHeuristic::addAssertions()"
@@ -177,19 +175,19 @@ void JustificationHeuristic::addAssertions
     << std::endl;
 
   // Save the 'real' assertions locally
-  for(unsigned i = 0; i < assertionsEnd; ++i)
+  for (size_t i = 0; i < assertionsEnd; i++)
+  {
     d_assertions.push_back(assertions[i]);
+  }
 
   // Save mapping between ite skolems and ite assertions
-  for(IteSkolemMap::iterator i = iteSkolemMap.begin();
-      i != iteSkolemMap.end(); ++i) {
-
-    Trace("decision::jh::ite")
-      << " jh-ite: " << (i->first) << " maps to "
-      << assertions[(i->second)] << std::endl;
-    Assert(i->second >= assertionsEnd && i->second < assertions.size());
+  for (const std::pair<const Node, unsigned> &i : assertions.getIteSkolemMap())
+  {
+    Trace("decision::jh::ite") << " jh-ite: " << (i.first) << " maps to "
+                               << assertions[(i.second)] << std::endl;
+    Assert(i.second >= assertionsEnd && i.second < assertions.size());
 
-    d_iteAssertions[i->first] = assertions[i->second];
+    d_iteAssertions[i.first] = assertions[i.second];
   }
 
   // Automatic weight computation
index a70bee02c093a5dbb8e229dcf549318d9beab652..0cd45ada781ba792337ec57580749d60e05f2b21 100644 (file)
@@ -32,6 +32,7 @@
 #include "decision/decision_engine.h"
 #include "decision/decision_strategy.h"
 #include "expr/node.h"
+#include "preprocessing/assertion_pipeline.h"
 #include "prop/sat_solver_types.h"
 
 namespace CVC4 {
@@ -119,9 +120,8 @@ public:
 
   prop::SatLiteral getNext(bool &stopSearch) override;
 
-  void addAssertions(const std::vector<Node> &assertions,
-                     unsigned assertionsEnd,
-                     IteSkolemMap iteSkolemMap) override;
+  void addAssertions(
+      const preprocessing::AssertionPipeline &assertions) override;
 
  private:
   /* getNext with an option to specify threshold */
index 92ed555fd0d88c1991011b02c8d2b366ec0214c9..23bf0e01f1801724b4f6302e54d1b2d35212003d 100644 (file)
 #ifndef __CVC4_PRIVATE_LIBRARY_H
 #define __CVC4_PRIVATE_LIBRARY_H
 
-#if ! (defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST) || defined(__BUILDING_CVC4PARSERLIB) || defined(__BUILDING_CVC4PARSERLIB_UNIT_TEST) || defined(__BUILDING_CVC4DRIVER))
+#if !(defined(__BUILDING_CVC4LIB) || defined(__BUILDING_CVC4LIB_UNIT_TEST) \
+      || defined(__BUILDING_CVC4PARSERLIB)                                 \
+      || defined(__BUILDING_CVC4PARSERLIB_UNIT_TEST)                       \
+      || defined(__BUILDING_CVC4DRIVER))
 #  error A "private library" CVC4 header was included when not building the library, driver, or private unit test code.
 #endif /* ! (__BUILDING_CVC4LIB || __BUILDING_CVC4LIB_UNIT_TEST || __BUILDING_CVC4PARSERLIB || __BUILDING_CVC4PARSERLIB_UNIT_TEST || __BUILDING_CVC4DRIVER) */
 
diff --git a/src/preprocessing/assertion_pipeline.cpp b/src/preprocessing/assertion_pipeline.cpp
new file mode 100644 (file)
index 0000000..0bce3b8
--- /dev/null
@@ -0,0 +1,59 @@
+/*********************                                                        */
+/*! \file assertion_pipeline.cpp
+ ** \verbatim
+ ** Top contributors (to current version):
+ **   Andres Noetzli
+ ** This file is part of the CVC4 project.
+ ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS
+ ** in the top-level source directory) and their institutional affiliations.
+ ** All rights reserved.  See the file COPYING in the top-level source
+ ** directory for licensing information.\endverbatim
+ **
+ ** \brief AssertionPipeline stores a list of assertions modified by
+ ** preprocessing passes
+ **/
+
+#include "preprocessing/assertion_pipeline.h"
+
+#include "expr/node_manager.h"
+#include "proof/proof.h"
+#include "proof/proof_manager.h"
+
+namespace CVC4 {
+namespace preprocessing {
+
+AssertionPipeline::AssertionPipeline() : d_realAssertionsEnd(0) {}
+
+void AssertionPipeline::replace(size_t i, Node n)
+{
+  PROOF(ProofManager::currentPM()->addDependence(n, d_nodes[i]););
+  d_nodes[i] = n;
+}
+
+void AssertionPipeline::replace(size_t i,
+                                Node n,
+                                const std::vector<Node>& addnDeps)
+{
+  PROOF(ProofManager::currentPM()->addDependence(n, d_nodes[i]);
+        for (const auto& addnDep
+             : addnDeps) {
+          ProofManager::currentPM()->addDependence(n, addnDep);
+        });
+  d_nodes[i] = n;
+}
+
+void AssertionPipeline::replace(size_t i, const std::vector<Node>& ns)
+{
+  PROOF(
+      for (const auto& n
+           : ns) { ProofManager::currentPM()->addDependence(n, d_nodes[i]); });
+  d_nodes[i] = NodeManager::currentNM()->mkConst<bool>(true);
+
+  for (const auto& n : ns)
+  {
+    d_nodes.push_back(n);
+  }
+}
+
+}  // namespace preprocessing
+}  // namespace CVC4
diff --git a/src/preprocessing/assertion_pipeline.h b/src/preprocessing/assertion_pipeline.h
new file mode 100644 (file)
index 0000000..af7a8dc
--- /dev/null
@@ -0,0 +1,101 @@
+/*********************                                                        */
+/*! \file assertion_pipeline.h
+ ** \verbatim
+ ** Top contributors (to current version):
+ **   Andres Noetzli
+ ** This file is part of the CVC4 project.
+ ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS
+ ** in the top-level source directory) and their institutional affiliations.
+ ** All rights reserved.  See the file COPYING in the top-level source
+ ** directory for licensing information.\endverbatim
+ **
+ ** \brief AssertionPipeline stores a list of assertions modified by
+ ** preprocessing passes
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__PREPROCESSING__ASSERTION_PIPELINE_H
+#define __CVC4__PREPROCESSING__ASSERTION_PIPELINE_H
+
+#include <vector>
+
+#include "expr/node.h"
+#include "smt/term_formula_removal.h"
+
+namespace CVC4 {
+namespace preprocessing {
+
+/**
+ * Assertion Pipeline stores a list of assertions modified by preprocessing
+ * passes. It is assumed that all assertions after d_realAssertionsEnd were
+ * generated by ITE removal. Hence, d_iteSkolemMap maps into only these.
+ */
+class AssertionPipeline
+{
+ public:
+  AssertionPipeline();
+
+  size_t size() const { return d_nodes.size(); }
+
+  void resize(size_t n) { d_nodes.resize(n); }
+
+  void clear()
+  {
+    d_nodes.clear();
+    d_realAssertionsEnd = 0;
+  }
+
+  Node& operator[](size_t i) { return d_nodes[i]; }
+  const Node& operator[](size_t i) const { return d_nodes[i]; }
+  void push_back(Node n) { d_nodes.push_back(n); }
+
+  std::vector<Node>& ref() { return d_nodes; }
+  const std::vector<Node>& ref() const { return d_nodes; }
+
+  std::vector<Node>::const_iterator begin() const { return d_nodes.cbegin(); }
+  std::vector<Node>::const_iterator end() const { return d_nodes.cend(); }
+
+  /*
+   * Replaces assertion i with node n and records the dependency between the
+   * original assertion and its replacement.
+   */
+  void replace(size_t i, Node n);
+
+  /*
+   * Replaces assertion i with node n and records that this replacement depends
+   * on assertion i and the nodes listed in addnDeps. The dependency
+   * information is used for unsat cores and proofs.
+   */
+  void replace(size_t i, Node n, const std::vector<Node>& addnDeps);
+
+  /*
+   * Replaces an assertion with a vector of assertions and records the
+   * dependencies.
+   */
+  void replace(size_t i, const std::vector<Node>& ns);
+
+  IteSkolemMap& getIteSkolemMap() { return d_iteSkolemMap; }
+  const IteSkolemMap& getIteSkolemMap() const { return d_iteSkolemMap; }
+
+  size_t getRealAssertionsEnd() const { return d_realAssertionsEnd; }
+
+  void updateRealAssertionsEnd() { d_realAssertionsEnd = d_nodes.size(); }
+
+ private:
+  std::vector<Node> d_nodes;
+
+  /**
+   * Map from skolem variables to index in d_assertions containing
+   * corresponding introduced Boolean ite
+   */
+  IteSkolemMap d_iteSkolemMap;
+
+  /** Size of d_nodes when preprocessing starts */
+  size_t d_realAssertionsEnd;
+}; /* class AssertionPipeline */
+
+}  // namespace preprocessing
+}  // namespace CVC4
+
+#endif /* __CVC4__PREPROCESSING__ASSERTION_PIPELINE_H */
index 6fb4b77937ef2f5ca9e3a1d51f040b196a620371..f5c3520d01545a386764dca6ee3f24dae0819004 100644 (file)
@@ -44,8 +44,9 @@ PreprocessingPassResult ApplySubsts::applyInternal(
     // When solving incrementally, all substitutions are piled into the
     // assertion at d_substitutionsIndex: we don't want to apply substitutions
     // to this assertion or information will be lost.
-    context::CDO<unsigned>& substs_index =
-        assertionsToPreprocess->getSubstitutionsIndex();
+    unsigned substs_index = d_preprocContext->getSubstitutionsIndex();
+    theory::SubstitutionMap& substMap =
+        d_preprocContext->getTopLevelSubstitutions();
     unsigned size = assertionsToPreprocess->size();
     unsigned substitutionAssertion = substs_index > 0 ? substs_index : size;
     for (unsigned i = 0; i < size; ++i)
@@ -57,11 +58,9 @@ PreprocessingPassResult ApplySubsts::applyInternal(
       Trace("apply-substs") << "applying to " << (*assertionsToPreprocess)[i]
                         << std::endl;
       d_preprocContext->spendResource(options::preprocessStep());
-      assertionsToPreprocess->replace(
-          i,
-          theory::Rewriter::rewrite(
-              assertionsToPreprocess->getTopLevelSubstitutions().apply(
-                  (*assertionsToPreprocess)[i])));
+      assertionsToPreprocess->replace(i,
+                                      theory::Rewriter::rewrite(substMap.apply(
+                                          (*assertionsToPreprocess)[i])));
       Trace("apply-substs") << "  got " << (*assertionsToPreprocess)[i]
                         << std::endl;
     }
index 81588d039b29d3a9e947c000a7cbc17613ffe27c..616ecd969000bece4b4c927fdfe5c71fe88470da 100644 (file)
@@ -188,7 +188,7 @@ PreprocessingPassResult MipLibTrick::applyInternal(
       propagator->getBackEdges();
   unordered_set<unsigned long> removeAssertions;
   SubstitutionMap& top_level_substs =
-      assertionsToPreprocess->getTopLevelSubstitutions();
+      d_preprocContext->getTopLevelSubstitutions();
 
   NodeManager* nm = NodeManager::currentNM();
   Node zero = nm->mkConst(Rational(0)), one = nm->mkConst(Rational(1));
index e2ce1c3011363e3f42e10217854727a8f6fe5c36..653aed8adb19fcfa609f6d7d03320f7d5ae690a4 100644 (file)
@@ -76,8 +76,7 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
 
   // Assert all the assertions to the propagator
   Trace("non-clausal-simplify") << "asserting to propagator" << std::endl;
-  context::CDO<unsigned>& substs_index =
-      assertionsToPreprocess->getSubstitutionsIndex();
+  unsigned substs_index = d_preprocContext->getSubstitutionsIndex();
   for (size_t i = 0, size = assertionsToPreprocess->size(); i < size; ++i)
   {
     Assert(Rewriter::rewrite((*assertionsToPreprocess)[i])
@@ -114,7 +113,7 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
       << " learned literals." << std::endl;
   // No conflict, go through the literals and solve them
   SubstitutionMap& top_level_substs =
-      assertionsToPreprocess->getTopLevelSubstitutions();
+      d_preprocContext->getTopLevelSubstitutions();
   SubstitutionMap constantPropagations(d_preprocContext->getUserContext());
   SubstitutionMap newSubstitutions(d_preprocContext->getUserContext());
   SubstitutionMap::iterator pos;
index 6a7078696e27d6b4079e242aa5c852c569306ad1..6a1d89d33a39a687ffc09e0a5a0f02d6d3b8d62d 100644 (file)
 
 #include "preprocessing/preprocessing_pass.h"
 
-#include "expr/node_manager.h"
-#include "proof/proof.h"
 #include "smt/dump.h"
 #include "smt/smt_statistics_registry.h"
 
 namespace CVC4 {
 namespace preprocessing {
 
-AssertionPipeline::AssertionPipeline(context::Context* context)
-    : d_substitutionsIndex(context, 0),
-      d_topLevelSubstitutions(context),
-      d_realAssertionsEnd(0)
-{
-}
-
-void AssertionPipeline::replace(size_t i, Node n) {
-  PROOF(ProofManager::currentPM()->addDependence(n, d_nodes[i]););
-  d_nodes[i] = n;
-}
-
-void AssertionPipeline::replace(size_t i,
-                                Node n,
-                                const std::vector<Node>& addnDeps)
-{
-  PROOF(ProofManager::currentPM()->addDependence(n, d_nodes[i]);
-        for (const auto& addnDep
-             : addnDeps) {
-          ProofManager::currentPM()->addDependence(n, addnDep);
-        });
-  d_nodes[i] = n;
-}
-
-void AssertionPipeline::replace(size_t i, const std::vector<Node>& ns)
-{
-  PROOF(
-      for (const auto& n
-           : ns) { ProofManager::currentPM()->addDependence(n, d_nodes[i]); });
-  d_nodes[i] = NodeManager::currentNM()->mkConst<bool>(true);
-
-  for (const auto& n : ns)
-  {
-    d_nodes.push_back(n);
-  }
-}
-
 PreprocessingPassResult PreprocessingPass::apply(
     AssertionPipeline* assertionsToPreprocess) {
   TimerStat::CodeTimer codeTimer(d_timer);
index 4143f2d4bbf35152b2f18b5f577411886c1e2470..448cacb87782d060b79ebde421c7fa3cc55779d6 100644 (file)
 #define __CVC4__PREPROCESSING__PREPROCESSING_PASS_H
 
 #include <string>
-#include <vector>
 
-#include "context/cdo.h"
-#include "expr/node.h"
+#include "preprocessing/assertion_pipeline.h"
 #include "preprocessing/preprocessing_pass_context.h"
 #include "smt/smt_engine_scope.h"
-#include "smt/term_formula_removal.h"
 #include "theory/logic_info.h"
-#include "theory/substitutions.h"
 
 namespace CVC4 {
 namespace preprocessing {
 
-/**
- * Assertion Pipeline stores a list of assertions modified by preprocessing
- * passes.
- */
-class AssertionPipeline
-{
- public:
-  AssertionPipeline(context::Context* context);
-
-  size_t size() const { return d_nodes.size(); }
-
-  void resize(size_t n) { d_nodes.resize(n); }
-
-  void clear()
-  {
-    d_nodes.clear();
-    d_realAssertionsEnd = 0;
-  }
-
-  Node& operator[](size_t i) { return d_nodes[i]; }
-  const Node& operator[](size_t i) const { return d_nodes[i]; }
-  void push_back(Node n) { d_nodes.push_back(n); }
-
-  std::vector<Node>& ref() { return d_nodes; }
-  const std::vector<Node>& ref() const { return d_nodes; }
-
-  std::vector<Node>::const_iterator begin() const { return d_nodes.cbegin(); }
-  std::vector<Node>::const_iterator end() const { return d_nodes.cend(); }
-
-  /*
-   * Replaces assertion i with node n and records the dependency between the
-   * original assertion and its replacement.
-   */
-  void replace(size_t i, Node n);
-
-  /*
-   * Replaces assertion i with node n and records that this replacement depends
-   * on assertion i and the nodes listed in addnDeps. The dependency
-   * information is used for unsat cores and proofs.
-   */
-  void replace(size_t i, Node n, const std::vector<Node>& addnDeps);
-
-  /*
-   * Replaces an assertion with a vector of assertions and records the
-   * dependencies.
-   */
-  void replace(size_t i, const std::vector<Node>& ns);
-
-  IteSkolemMap& getIteSkolemMap() { return d_iteSkolemMap; }
-
-  context::CDO<unsigned>& getSubstitutionsIndex()
-  {
-    return d_substitutionsIndex;
-  }
-
-  theory::SubstitutionMap& getTopLevelSubstitutions()
-  {
-    return d_topLevelSubstitutions;
-  }
-
-  size_t getRealAssertionsEnd() { return d_realAssertionsEnd; }
-
-  void updateRealAssertionsEnd() { d_realAssertionsEnd = d_nodes.size(); }
-
- private:
-  std::vector<Node> d_nodes;
-
-  /**
-   * Map from skolem variables to index in d_assertions containing
-   * corresponding introduced Boolean ite
-   */
-  IteSkolemMap d_iteSkolemMap;
-
-  /* Index for where to store substitutions */
-  context::CDO<unsigned> d_substitutionsIndex;
-
-  /* The top level substitutions */
-  theory::SubstitutionMap d_topLevelSubstitutions;
-
-  /** Size of d_nodes when preprocessing starts */
-  size_t d_realAssertionsEnd;
-}; /* class AssertionPipeline */
-
 /**
  * Preprocessing passes return a result which indicates whether a conflict has
  * been detected during preprocessing.
index 15f5d3eb010482c4966b52167bc0689d0d6c8416..3f72a4559ed0ebdd71012c3de07cf6a4635bbe7c 100644 (file)
@@ -29,6 +29,8 @@ PreprocessingPassContext::PreprocessingPassContext(
     : d_smt(smt),
       d_resourceManager(resourceManager),
       d_iteRemover(iteRemover),
+      d_substitutionsIndex(smt->d_userContext, 0),
+      d_topLevelSubstitutions(smt->d_userContext),
       d_circuitPropagator(circuitPropagator),
       d_symsInAssertions(smt->d_userContext)
 {
index ae989d700bdae3f25cfa52a28e447f343515586b..3eb0f10b59286643769bf4bf3d3138d2d1e55cb3 100644 (file)
@@ -21,6 +21,7 @@
 #ifndef __CVC4__PREPROCESSING__PREPROCESSING_PASS_CONTEXT_H
 #define __CVC4__PREPROCESSING__PREPROCESSING_PASS_CONTEXT_H
 
+#include "context/cdo.h"
 #include "context/context.h"
 #include "decision/decision_engine.h"
 #include "preprocessing/util/ite_utilities.h"
@@ -70,6 +71,16 @@ class PreprocessingPassContext
   /* Widen the logic to include the given theory. */
   void widenLogic(theory::TheoryId id);
 
+  unsigned getSubstitutionsIndex() const { return d_substitutionsIndex.get(); }
+
+  void setSubstitutionsIndex(unsigned i) { d_substitutionsIndex = i; }
+
+  /** Gets a reference to the top-level substitution map */
+  theory::SubstitutionMap& getTopLevelSubstitutions()
+  {
+    return d_topLevelSubstitutions;
+  }
+
   /* Enable Integers. */
   void enableIntegers();
 
@@ -90,6 +101,12 @@ class PreprocessingPassContext
   /** Instance of the ITE remover */
   RemoveTermFormulas* d_iteRemover;
 
+  /* Index for where to store substitutions */
+  context::CDO<unsigned> d_substitutionsIndex;
+
+  /* The top level substitutions */
+  theory::SubstitutionMap d_topLevelSubstitutions;
+
   /** Instance of the circuit propagator */
   theory::booleans::CircuitPropagator* d_circuitPropagator;
 
index 73264daa505a3f62ee94a69993d90c4565f2f2c0..eeacb9c3f2033df098dba59e9b98d7471ff8b13c 100644 (file)
@@ -568,7 +568,7 @@ class SmtEnginePrivate : public NodeManagerListener {
         d_managedReplayLog(),
         d_listenerRegistrations(new ListenerRegistrationList()),
         d_propagator(true, true),
-        d_assertions(d_smt.d_userContext),
+        d_assertions(),
         d_assertionsProcessed(smt.d_userContext, false),
         d_fakeContext(),
         d_abstractValueMap(&d_fakeContext),
@@ -715,7 +715,7 @@ class SmtEnginePrivate : public NodeManagerListener {
   Node applySubstitutions(TNode node)
   {
     return Rewriter::rewrite(
-        d_assertions.getTopLevelSubstitutions().apply(node));
+        d_preprocessingPassContext->getTopLevelSubstitutions().apply(node));
   }
 
   /**
@@ -3113,7 +3113,8 @@ void SmtEnginePrivate::processAssertions() {
   spendResource(options::preprocessStep());
   Assert(d_smt.d_fullyInited);
   Assert(d_smt.d_pendingPops == 0);
-  SubstitutionMap& top_level_substs = d_assertions.getTopLevelSubstitutions();
+  SubstitutionMap& top_level_substs =
+      d_preprocessingPassContext->getTopLevelSubstitutions();
 
   // Dump the assertions
   dumpAssertions("pre-everything", d_assertions);
@@ -3138,7 +3139,7 @@ void SmtEnginePrivate::processAssertions() {
     // proper data structure.
 
     // Placeholder for storing substitutions
-    d_assertions.getSubstitutionsIndex() = d_assertions.size();
+    d_preprocessingPassContext->setSubstitutionsIndex(d_assertions.size());
     d_assertions.push_back(NodeManager::currentNM()->mkConst<bool>(true));
   }
 
@@ -3478,9 +3479,7 @@ void SmtEnginePrivate::processAssertions() {
   if(noConflict) {
     Chat() << "pushing to decision engine..." << endl;
     Assert(iteRewriteAssertionsEnd == d_assertions.size());
-    d_smt.d_decisionEngine->addAssertions(d_assertions.ref(),
-                                          d_assertions.getRealAssertionsEnd(),
-                                          getIteSkolemMap());
+    d_smt.d_decisionEngine->addAssertions(d_assertions);
   }
 
   // end: INVARIANT to maintain: no reordering of assertions or
index 95a60afacb8fff6d672f0ade7f525238e5c9db57..8c9b39ea489c0ce38bb67d040114040e5b11d807 100644 (file)
@@ -67,10 +67,7 @@ InstStrategyCegqi::InstStrategyCegqi(QuantifiersEngine* qe)
   d_check_vts_lemma_lc = false;
 }
 
-InstStrategyCegqi::~InstStrategyCegqi()
-{
-
-}
+InstStrategyCegqi::~InstStrategyCegqi() {}
 
 bool InstStrategyCegqi::needsCheck(Theory::Effort e)
 {
index 92a355348541c5c3e60a9ea4de0cd71033a82d8c..95ec24df9c47ec9e1c2ebb2c9503173df4b3fa63 100644 (file)
@@ -1194,16 +1194,17 @@ bool MatchGen::reset_round(QuantConflictFind* p)
     d_qni_gterm_rep[it->first] = p->getRepresentative( it->second );
   }
   if( d_type==typ_ground ){
-    //int e = p->evaluate( d_n );
-    //if( e==1 ){
+    // int e = p->evaluate( d_n );
+    // if( e==1 ){
     //  d_ground_eval[0] = p->d_true;
     //}else if( e==-1 ){
     //  d_ground_eval[0] = p->d_false;
     //}
-    //modified
+    // modified
     TermDb* tdb = p->getTermDatabase();
     QuantifiersEngine* qe = p->getQuantifiersEngine();
-    for( unsigned i=0; i<2; i++ ){
+    for (unsigned i = 0; i < 2; i++)
+    {
       if (tdb->isEntailed(d_n, i == 0))
       {
         d_ground_eval[0] = i==0 ? p->d_true : p->d_false;
@@ -1220,7 +1221,7 @@ bool MatchGen::reset_round(QuantConflictFind* p)
     {
       if (!expr::hasBoundVar(d_n[i]))
       {
-        TNode t = tdb->getEntailedTerm(d_n[i]);        
+        TNode t = tdb->getEntailedTerm(d_n[i]);
         if (qe->inConflict())
         {
           return false;
index fe1dc30a41dd655f9845f18a7500dd2ba6d280cf..09525712fc9bc13be4dba956be5ceb521b1d47ae 100644 (file)
@@ -307,8 +307,8 @@ bool SygusRepairConst::repairSolution(const std::vector<Node>& candidates,
   }
   Trace("cegqi-engine") << "...success:" << std::endl;
   Trace("cegqi-engine") << ss.str();
-  Trace("sygus-repair-const") << "Repaired constants in solution : "
-                              << std::endl;
+  Trace("sygus-repair-const")
+      << "Repaired constants in solution : " << std::endl;
   Trace("sygus-repair-const") << ss.str();
   return true;
 }
index 37276ac5eab3cc8a8457b7224522149ed7d14f6c..b9c3ccc4e602b4911aef5f414ab2818dfbeb21f5 100644 (file)
@@ -29,6 +29,7 @@
 #include "options/options.h"
 #include "options/proof_options.h"
 #include "options/quantifiers_options.h"
+#include "preprocessing/assertion_pipeline.h"
 #include "proof/cnf_proof.h"
 #include "proof/lemma_proof.h"
 #include "proof/proof_manager.h"
@@ -53,6 +54,7 @@
 
 using namespace std;
 
+using namespace CVC4::preprocessing;
 using namespace CVC4::theory;
 
 namespace CVC4 {
@@ -1818,8 +1820,7 @@ theory::LemmaStatus TheoryEngine::lemma(TNode node,
     d_channels->getLemmaOutputChannel()->notifyNewLemma(node.toExpr());
   }
 
-  std::vector<Node> additionalLemmas;
-  IteSkolemMap iteSkolemMap;
+  AssertionPipeline additionalLemmas;
 
   // Run theory preprocessing, maybe
   Node ppNode = preprocess ? this->preprocess(node) : Node(node);
@@ -1827,9 +1828,11 @@ theory::LemmaStatus TheoryEngine::lemma(TNode node,
   // Remove the ITEs
   Debug("ite") << "Remove ITE from " << ppNode << std::endl;
   additionalLemmas.push_back(ppNode);
-  d_tform_remover.run(additionalLemmas, iteSkolemMap);
+  additionalLemmas.updateRealAssertionsEnd();
+  d_tform_remover.run(additionalLemmas.ref(),
+                      additionalLemmas.getIteSkolemMap());
   Debug("ite") << "..done " << additionalLemmas[0] << std::endl;
-  additionalLemmas[0] = theory::Rewriter::rewrite(additionalLemmas[0]);
+  additionalLemmas.replace(0, theory::Rewriter::rewrite(additionalLemmas[0]));
 
   if(Debug.isOn("lemma-ites")) {
     Debug("lemma-ites") << "removed ITEs from lemma: " << ppNode << endl;
@@ -1846,19 +1849,19 @@ theory::LemmaStatus TheoryEngine::lemma(TNode node,
   // assert to prop engine
   d_propEngine->assertLemma(additionalLemmas[0], negated, removable, rule, node);
   for (unsigned i = 1; i < additionalLemmas.size(); ++ i) {
-    additionalLemmas[i] = theory::Rewriter::rewrite(additionalLemmas[i]);
+    additionalLemmas.replace(i, theory::Rewriter::rewrite(additionalLemmas[i]));
     d_propEngine->assertLemma(additionalLemmas[i], false, removable, rule, node);
   }
 
   // WARNING: Below this point don't assume additionalLemmas[0] to be not negated.
   if(negated) {
-    additionalLemmas[0] = additionalLemmas[0].notNode();
+    additionalLemmas.replace(0, additionalLemmas[0].notNode());
     negated = false;
   }
 
   // assert to decision engine
   if(!removable) {
-    d_decisionEngine->addAssertions(additionalLemmas, 1, iteSkolemMap);
+    d_decisionEngine->addAssertions(additionalLemmas);
   }
 
   // Mark that we added some lemmas
index f238ba8be71ad4fafaeaa8136817f7d2a706cc5a..8ba6da0bfbc494e7612967f960b3534e9be8a11f 100644 (file)
@@ -2378,8 +2378,7 @@ class TheoryBVGaussWhite : public CxxTest::TestSuite
 
     Node a = d_nm->mkNode(kind::AND, d_nm->mkNode(kind::AND, eq1, eq2), eq3);
 
-    context::Context context;
-    AssertionPipeline apipe(&context);
+    AssertionPipeline apipe;
     apipe.push_back(a);
     passes::BVGauss bgauss(nullptr);
     std::unordered_map<Node, Node, NodeHashFunction> res;
@@ -2461,8 +2460,7 @@ class TheoryBVGaussWhite : public CxxTest::TestSuite
 
     Node a = d_nm->mkNode(kind::AND, d_nm->mkNode(kind::AND, eq1, eq2), eq3);
 
-    context::Context context;
-    AssertionPipeline apipe(&context);
+    AssertionPipeline apipe;
     apipe.push_back(a);
     apipe.push_back(eq4);
     apipe.push_back(eq5);
@@ -2513,8 +2511,7 @@ class TheoryBVGaussWhite : public CxxTest::TestSuite
             d_p),
         d_nine);
 
-    context::Context context;
-    AssertionPipeline apipe(&context);
+    AssertionPipeline apipe;
     apipe.push_back(eq1);
     apipe.push_back(eq2);
     passes::BVGauss bgauss(nullptr);