Eliminate PREPROCESS lemma property (#5827)
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>
Mon, 1 Feb 2021 20:55:19 +0000 (14:55 -0600)
committerGitHub <noreply@github.com>
Mon, 1 Feb 2021 20:55:19 +0000 (14:55 -0600)
This is now possible since we always preprocess lemmas.

Note that the LemmaProperty on inferences may be redundant throughout the non-linear solver now.

13 files changed:
src/theory/arith/arith_preprocess.cpp
src/theory/arith/inference_manager.cpp
src/theory/arith/inference_manager.h
src/theory/arith/nl/iand_solver.cpp
src/theory/arith/nl/transcendental/exponential_solver.cpp
src/theory/arith/nl/transcendental/sine_solver.cpp
src/theory/ext_theory.cpp
src/theory/fp/theory_fp.cpp
src/theory/output_channel.cpp
src/theory/output_channel.h
src/theory/quantifiers/cegqi/inst_strategy_cegqi.cpp
src/theory/quantifiers/fmf/bounded_integers.cpp
src/theory/quantifiers_engine.cpp

index 142f02eab38b4284544124c5dfb119bb005dec40..ecab1b92c7e45bf7dd2c2728a6271548c766ad1f 100644 (file)
@@ -49,7 +49,7 @@ bool ArithPreprocess::reduceAssertion(TNode atom)
   // tn is of kind REWRITE, turn this into a LEMMA here
   TrustNode tlem = TrustNode::mkTrustLemma(tn.getProven(), tn.getGenerator());
   // must preprocess
-  d_im.trustedLemma(tlem, LemmaProperty::PREPROCESS);
+  d_im.trustedLemma(tlem);
   // mark the atom as reduced
   d_reduced[atom] = true;
   return true;
index e79c12155e8ca1d8e4d4e514c671e15563c39a7c..6a1f898d3a9e6604f392c1f691531c467151fde2 100644 (file)
@@ -25,7 +25,7 @@ namespace arith {
 InferenceManager::InferenceManager(TheoryArith& ta,
                                    ArithState& astate,
                                    ProofNodeManager* pnm)
-    : InferenceManagerBuffered(ta, astate, pnm), d_lemmasPp(ta.getUserContext())
+    : InferenceManagerBuffered(ta, astate, pnm)
 {
 }
 
@@ -110,25 +110,12 @@ std::size_t InferenceManager::numWaitingLemmas() const
 bool InferenceManager::hasCachedLemma(TNode lem, LemmaProperty p)
 {
   Node rewritten = Rewriter::rewrite(lem);
-  if (isLemmaPropertyPreprocess(p))
-  {
-    return d_lemmasPp.find(rewritten) != d_lemmasPp.end();
-  }
   return TheoryInferenceManager::hasCachedLemma(rewritten, p);
 }
 
 bool InferenceManager::cacheLemma(TNode lem, LemmaProperty p)
 {
   Node rewritten = Rewriter::rewrite(lem);
-  if (isLemmaPropertyPreprocess(p))
-  {
-    if (d_lemmasPp.find(rewritten) != d_lemmasPp.end())
-    {
-      return false;
-    }
-    d_lemmasPp.insert(rewritten);
-    return true;
-  }
   return TheoryInferenceManager::cacheLemma(rewritten, p);
 }
 
index 0f2614fd7c3a168c2e310a692a5f1655bf031c96..6de65d677b7851404d8f16a655d8cef99bb7f52c 100644 (file)
@@ -116,10 +116,6 @@ class InferenceManager : public InferenceManagerBuffered
 
   /** The waiting lemmas. */
   std::vector<std::unique_ptr<ArithLemma>> d_waitingLem;
-
-  /** cache of all preprocessed lemmas sent on the output channel
-   * (user-context-dependent) */
-  NodeSet d_lemmasPp;
 };
 
 }  // namespace arith
index f908145fee7326b8a8795243ed2917b7e6e67e7d..5415e6a86c1bf2a444a013ea9e110a9aa9ceb277 100644 (file)
@@ -150,24 +150,20 @@ void IAndSolver::checkFullRefine()
         Node lem = sumBasedLemma(i);  // add lemmas based on sum mode
         Trace("iand-lemma")
             << "IAndSolver::Lemma: " << lem << " ; SUM_REFINE" << std::endl;
-        // lemma can contain div/mod so need to tag it with the PREPROCESS lemma property
-        d_im.addPendingArithLemma(lem,
-                                  InferenceId::NL_IAND_SUM_REFINE,
-                                  nullptr,
-                                  true,
-                                  LemmaProperty::PREPROCESS);
+        // note that lemma can contain div/mod, and will be preprocessed in the
+        // prop engine
+        d_im.addPendingArithLemma(
+            lem, InferenceId::NL_IAND_SUM_REFINE, nullptr, true);
       }
       else if (options::iandMode() == options::IandMode::BITWISE)
       {
         Node lem = bitwiseLemma(i);  // check for violated bitwise axioms
         Trace("iand-lemma")
             << "IAndSolver::Lemma: " << lem << " ; BITWISE_REFINE" << std::endl;
-        // lemma can contain div/mod so need to tag it with the PREPROCESS lemma property
-        d_im.addPendingArithLemma(lem,
-                                  InferenceId::NL_IAND_BITWISE_REFINE,
-                                  nullptr,
-                                  true,
-                                  LemmaProperty::PREPROCESS);
+        // note that lemma can contain div/mod, and will be preprocessed in the
+        // prop engine
+        d_im.addPendingArithLemma(
+            lem, InferenceId::NL_IAND_BITWISE_REFINE, nullptr, true);
       }
       else
       {
index cbed48a2a972de01548b1af459c26ab1d0547aac..b0254d2c5de9c80d1e9177c25ff672450c55a449 100644 (file)
@@ -45,8 +45,7 @@ void ExponentialSolver::doPurification(TNode a, TNode new_a, TNode y)
   // note we must do preprocess on this lemma
   Trace("nl-ext-lemma") << "NonlinearExtension::Lemma : purify : " << lem
                         << std::endl;
-  NlLemma nlem(
-      lem, LemmaProperty::PREPROCESS, nullptr, InferenceId::NL_T_PURIFY_ARG);
+  NlLemma nlem(lem, LemmaProperty::NONE, nullptr, InferenceId::NL_T_PURIFY_ARG);
   d_data->d_im.addPendingArithLemma(nlem);
 }
 
index 40137095cb5531e5b8e9ad8372115b28d9faebdd..a88dd7faf808acef67e4f866f4f41a449c0ca943 100644 (file)
@@ -79,8 +79,7 @@ void SineSolver::doPhaseShift(TNode a, TNode new_a, TNode y)
   // note we must do preprocess on this lemma
   Trace("nl-ext-lemma") << "NonlinearExtension::Lemma : purify : " << lem
                         << std::endl;
-  NlLemma nlem(
-      lem, LemmaProperty::PREPROCESS, proof, InferenceId::NL_T_PURIFY_ARG);
+  NlLemma nlem(lem, LemmaProperty::NONE, proof, InferenceId::NL_T_PURIFY_ARG);
   d_data->d_im.addPendingArithLemma(nlem);
 }
 
index ac08b15532459c659ccf7aa13697726cb69a45af..7a6d5c9abcc68bef679a8216f4991cfb8dfc4905 100644 (file)
@@ -371,7 +371,7 @@ bool ExtTheory::sendLemma(Node lem, bool preprocess)
     if (d_pp_lemmas.find(lem) == d_pp_lemmas.end())
     {
       d_pp_lemmas.insert(lem);
-      d_out.lemma(lem, LemmaProperty::PREPROCESS);
+      d_out.lemma(lem);
       return true;
     }
   }
index a71a2d0eb54f58605afdbb5fd8b3598972fe0f76..6df991ef932017a4f2c97060ab6a9cfcac91863a 100644 (file)
@@ -916,8 +916,9 @@ void TheoryFp::preRegisterTerm(TNode node)
 
 void TheoryFp::handleLemma(Node node) {
   Trace("fp") << "TheoryFp::handleLemma(): asserting " << node << std::endl;
-  // Preprocess has to be true because it contains embedded ITEs
-  d_out->lemma(node, LemmaProperty::PREPROCESS);
+  // will be preprocessed when sent, which is important because it contains
+  // embedded ITEs
+  d_out->lemma(node);
 }
 
 bool TheoryFp::propagateLit(TNode node)
index e63b784863a32410278b7690593490bb04057a16..e0bae8fae058c57f58d5645cd7245e6166d9d78b 100644 (file)
@@ -41,10 +41,6 @@ bool isLemmaPropertyRemovable(LemmaProperty p)
 {
   return (p & LemmaProperty::REMOVABLE) != LemmaProperty::NONE;
 }
-bool isLemmaPropertyPreprocess(LemmaProperty p)
-{
-  return (p & LemmaProperty::PREPROCESS) != LemmaProperty::NONE;
-}
 bool isLemmaPropertySendAtoms(LemmaProperty p)
 {
   return (p & LemmaProperty::SEND_ATOMS) != LemmaProperty::NONE;
@@ -67,10 +63,6 @@ std::ostream& operator<<(std::ostream& out, LemmaProperty p)
     {
       out << " REMOVABLE";
     }
-    if (isLemmaPropertyPreprocess(p))
-    {
-      out << " PREPROCESS";
-    }
     if (isLemmaPropertySendAtoms(p))
     {
       out << " SEND_ATOMS";
index c3d4b6a4261e5cd3716cf056ffea05338fa42aef..313fe24cf5ad4dceae821b89e406c4e1a4b8c186 100644 (file)
@@ -37,12 +37,10 @@ enum class LemmaProperty : uint32_t
   NONE = 0,
   // whether the lemma is removable
   REMOVABLE = 1,
-  // whether the lemma needs preprocessing
-  PREPROCESS = 2,
   // whether the processing of the lemma should send atoms to the caller
-  SEND_ATOMS = 4,
+  SEND_ATOMS = 2,
   // whether the lemma is part of the justification for answering "sat"
-  NEEDS_JUSTIFY = 8
+  NEEDS_JUSTIFY = 4
 };
 /** Define operator lhs | rhs */
 LemmaProperty operator|(LemmaProperty lhs, LemmaProperty rhs);
@@ -54,8 +52,6 @@ LemmaProperty operator&(LemmaProperty lhs, LemmaProperty rhs);
 LemmaProperty& operator&=(LemmaProperty& lhs, LemmaProperty rhs);
 /** is the removable bit set on p? */
 bool isLemmaPropertyRemovable(LemmaProperty p);
-/** is the preprocess bit set on p? */
-bool isLemmaPropertyPreprocess(LemmaProperty p);
 /** is the send atoms bit set on p? */
 bool isLemmaPropertySendAtoms(LemmaProperty p);
 /** is the needs justify bit set on p? */
index 8a8678749228bafea5bc3457e1330775973ec43a..cb31e80d3148f2565be233ee66848900fd0abda3 100644 (file)
@@ -374,7 +374,7 @@ void InstStrategyCegqi::registerCounterexampleLemma(Node q, Node lem)
     ce_vars.push_back(tutil->getInstantiationConstant(q, i));
   }
   // send the lemma
-  d_quantEngine->getOutputChannel().lemma(lem, LemmaProperty::PREPROCESS);
+  d_quantEngine->getOutputChannel().lemma(lem);
   // get the preprocessed form of the lemma we just sent
   std::vector<Node> skolems;
   std::vector<Node> skAsserts;
index 0f17bb04a4711362f7da308b61106ff56de30b63..9144bca2a4062ec328eb8e479705d81e38e72172 100644 (file)
@@ -725,7 +725,7 @@ bool BoundedIntegers::getRsiSubsitution( Node q, Node v, std::vector< Node >& va
       nn = nn.substitute( vars.begin(), vars.end(), subs.begin(), subs.end() );
       Node lem = NodeManager::currentNM()->mkNode( LEQ, nn, d_range[q][v] );
       Trace("bound-int-lemma") << "*** Add lemma to minimize instantiated non-ground term " << lem << std::endl;
-      d_quantEngine->getOutputChannel().lemma(lem, LemmaProperty::PREPROCESS);
+      d_quantEngine->getOutputChannel().lemma(lem);
     }
     return false;
   }else{
index 2cc904ed1710b83cdd276bf6898b4fb1fd35d093..6338c30b3840f25561b63f57b5a659925c60960f 100644 (file)
@@ -781,8 +781,7 @@ void QuantifiersEngine::assertQuantifier( Node f, bool pol ){
         Trace("quantifiers-sk-debug")
             << "Skolemize lemma : " << slem << std::endl;
       }
-      getOutputChannel().trustedLemma(
-          lem, LemmaProperty::PREPROCESS | LemmaProperty::NEEDS_JUSTIFY);
+      getOutputChannel().trustedLemma(lem, LemmaProperty::NEEDS_JUSTIFY);
     }
     return;
   }
@@ -947,8 +946,7 @@ void QuantifiersEngine::flushLemmas(){
       const Node& lemw = d_lemmas_waiting[i];
       Trace("qe-lemma") << "Lemma : " << lemw << std::endl;
       itp = d_lemmasWaitingPg.find(lemw);
-      LemmaProperty p =
-          LemmaProperty::PREPROCESS | LemmaProperty::NEEDS_JUSTIFY;
+      LemmaProperty p = LemmaProperty::NEEDS_JUSTIFY;
       if (itp != d_lemmasWaitingPg.end())
       {
         TrustNode tlemw = TrustNode::mkTrustLemma(lemw, itp->second);