Minor cleaning of non-clausal simplification (#7886)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Thu, 6 Jan 2022 20:05:04 +0000 (14:05 -0600)
committerGitHub <noreply@github.com>
Thu, 6 Jan 2022 20:05:04 +0000 (14:05 -0600)
src/preprocessing/passes/non_clausal_simp.cpp
src/smt/preprocessor.cpp
src/theory/booleans/circuit_propagator.cpp
src/theory/booleans/circuit_propagator.h

index ff672b3685191a7249cac6620cb838a21f928d0e..89e40a0aa5b6ff87f3796b978fcc95393e01eccc 100644 (file)
@@ -68,20 +68,18 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
 {
   d_preprocContext->spendResource(Resource::PreprocessStep);
 
-  theory::booleans::CircuitPropagator* propagator =
-      d_preprocContext->getCircuitPropagator();
-
-  for (size_t i = 0, size = assertionsToPreprocess->size(); i < size; ++i)
+  if (Trace.isOn("non-clausal-simplify"))
   {
-    Trace("non-clausal-simplify") << "Assertion #" << i << " : "
-                                  << (*assertionsToPreprocess)[i] << std::endl;
+    for (size_t i = 0, size = assertionsToPreprocess->size(); i < size; ++i)
+    {
+      Trace("non-clausal-simplify")
+          << "Assertion #" << i << " : " << (*assertionsToPreprocess)[i]
+          << std::endl;
+    }
   }
 
-  if (propagator->getNeedsFinish())
-  {
-    propagator->finish();
-    propagator->setNeedsFinish(false);
-  }
+  theory::booleans::CircuitPropagator* propagator =
+      d_preprocContext->getCircuitPropagator();
   propagator->initialize();
 
   // Assert all the assertions to the propagator
@@ -111,7 +109,6 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
         << "conflict in non-clausal propagation" << std::endl;
     assertionsToPreprocess->clear();
     assertionsToPreprocess->pushBackTrusted(conf);
-    propagator->setNeedsFinish(true);
     return PreprocessingPassResult::CONFLICT;
   }
 
@@ -174,7 +171,6 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
         assertionsToPreprocess->clear();
         Node n = NodeManager::currentNM()->mkConst<bool>(false);
         assertionsToPreprocess->push_back(n, false, false, d_llpg.get());
-        propagator->setNeedsFinish(true);
         return PreprocessingPassResult::CONFLICT;
       }
     }
@@ -208,7 +204,6 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
         assertionsToPreprocess->clear();
         Node n = NodeManager::currentNM()->mkConst<bool>(false);
         assertionsToPreprocess->push_back(n);
-        propagator->setNeedsFinish(true);
         return PreprocessingPassResult::CONFLICT;
       }
       default:
@@ -247,11 +242,11 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
         {
           // Keep the literal
           learned_literals[j++] = learned_literals[i];
-          // Its a literal that could not be processed as a substitution or
-          // conflict. In this case, we notify the context of the learned
-          // literal, which will process it with the learned literal manager.
-          d_preprocContext->notifyLearnedLiteral(learnedLiteral);
         }
+        // Its a literal that could not be processed as a substitution or
+        // conflict. In this case, we notify the context of the learned
+        // literal, which will process it with the learned literal manager.
+        d_preprocContext->notifyLearnedLiteral(learnedLiteral);
         break;
     }
   }
@@ -431,8 +426,6 @@ PreprocessingPassResult NonClausalSimp::applyInternal(
     assertionsToPreprocess->conjoin(replIndex, newConj, pg);
   }
 
-  propagator->setNeedsFinish(true);
-
   // Note that typically ttls.apply(assert)==assert here.
   // However, this invariant is invalidated for cases where we use explicit
   // equality assertions for variables solved in incremental mode that already
index d7167c04c4392a5c5cc4c1df1dec40d373fe1ebb..985e811abfcf4ad3f054619977e5ae815c474331 100644 (file)
@@ -44,17 +44,11 @@ Preprocessor::Preprocessor(Env& env,
       d_exDefs(env),
       d_processor(env, stats)
 {
-}
 
-Preprocessor::~Preprocessor()
-{
-  if (d_propagator.getNeedsFinish())
-  {
-    d_propagator.finish();
-    d_propagator.setNeedsFinish(false);
-  }
 }
 
+Preprocessor::~Preprocessor() {}
+
 void Preprocessor::finishInit(TheoryEngine* te, prop::PropEngine* pe)
 {
   d_ppContext.reset(new preprocessing::PreprocessingPassContext(
index b570b6b3665352ab40cc4b4a0e2b08f727d8a37c..e12f5b521c64e195650389a31d30cc69edd44c8d 100644 (file)
@@ -56,10 +56,14 @@ CircuitPropagator::CircuitPropagator(Env& env, bool enableForward, bool enableBa
 {
 }
 
-void CircuitPropagator::finish()
+void CircuitPropagator::initialize()
 {
-  Trace("circuit-prop") << "FINISH" << std::endl;
-  d_context.pop();
+  if (d_needsFinish)
+  {
+    d_context.pop();
+  }
+  d_context.push();
+  d_needsFinish = true;
 }
 
 void CircuitPropagator::assertTrue(TNode assertion)
index 01bc0ad35b1ffd39a338303305806815ce4ea77d..bf299c0e168cdbd8d943643a281e838d81c8eb6f 100644 (file)
@@ -78,17 +78,10 @@ class CircuitPropagator : protected EnvObj
   }
 
   // Use custom context to ensure propagator is reset after use
-  void initialize() { d_context.push(); }
-
-  void setNeedsFinish(bool value) { d_needsFinish = value; }
-
-  bool getNeedsFinish() { return d_needsFinish; }
+  void initialize();
 
   std::vector<TrustNode>& getLearnedLiterals() { return d_learnedLiterals; }
 
-  /** Finish the computation and pop the internal context */
-  void finish();
-
   /** Assert for propagation */
   void assertTrue(TNode assertion);