Improve quantifiers engine wrt incremental presolve. Add regressions.
authorajreynol <andrew.j.reynolds@gmail.com>
Mon, 28 Sep 2015 14:18:32 +0000 (16:18 +0200)
committerajreynol <andrew.j.reynolds@gmail.com>
Mon, 28 Sep 2015 14:18:32 +0000 (16:18 +0200)
src/theory/quantifiers/term_database.cpp
src/theory/quantifiers_engine.cpp
src/theory/quantifiers_engine.h
test/regress/regress0/push-pop/Makefile.am
test/regress/regress0/push-pop/inc-double-u.smt2 [new file with mode: 0644]
test/regress/regress0/strings/Makefile.am
test/regress/regress0/strings/norn-360.smt2 [new file with mode: 0644]

index d6f8b3af7f43dd5c4150e6323bc732d14a2e4335..366c7ce072e5386ea1d4014f0b43632e99a4fe1e 100644 (file)
@@ -420,11 +420,13 @@ void TermDb::setHasTerm( Node n ) {
 }
 
 void TermDb::presolve() {
-  //reset the caches that are SAT context-independent
-  d_op_map.clear();
-  d_type_map.clear();
-  d_processed.clear();
-  d_iclosure_processed.clear();
+  if( options::incrementalSolving() ){
+    //reset the caches that are SAT context-independent
+    d_op_map.clear();
+    d_type_map.clear();
+    d_processed.clear();
+    d_iclosure_processed.clear();
+  }
 }
 
 void TermDb::reset( Theory::Effort effort ){
index e5b5c40805fed2b5381ace4ed0aa0fe81c12735c..f1c47a21a518c8b3edfdd2190b9843530ee2889e 100644 (file)
@@ -83,7 +83,11 @@ QuantifiersEngine::QuantifiersEngine(context::Context* c, context::UserContext*
 d_te( te ),
 d_lemmas_produced_c(u),
 d_skolemized(u),
-d_presolve(u, true){
+d_presolve(u, true),
+d_presolve_in(u),
+d_presolve_cache(u),
+d_presolve_cache_wq(u),
+d_presolve_cache_wic(u){
   d_eq_query = new EqualityQueryQuantifiersEngine( this );
   d_term_db = new quantifiers::TermDb( c, u, this );
   d_tr_trie = new inst::TriggerTrie;
@@ -300,13 +304,12 @@ void QuantifiersEngine::presolve() {
   }
   d_term_db->presolve();
   d_presolve = false;
-  //clear presolve cache
-  for( unsigned i=0; i<d_presolve_cache.size(); i++ ){
-    addTermToDatabase( d_presolve_cache[i], d_presolve_cache_wq[i], d_presolve_cache_wic[i] );
+  //add all terms to database
+  if( options::incrementalSolving() ){
+    for( unsigned i=0; i<d_presolve_cache.size(); i++ ){
+      addTermToDatabase( d_presolve_cache[i], d_presolve_cache_wq[i], d_presolve_cache_wic[i] );
+    }
   }
-  d_presolve_cache.clear();
-  d_presolve_cache_wq.clear();
-  d_presolve_cache_wic.clear();
 }
 
 void QuantifiersEngine::check( Theory::Effort e ){
@@ -627,11 +630,16 @@ quantifiers::TermDbSygus* QuantifiersEngine::getTermDatabaseSygus() {
 }
 
 void QuantifiersEngine::addTermToDatabase( Node n, bool withinQuant, bool withinInstClosure ){
-  if( d_presolve ){
-    d_presolve_cache.push_back( n );
-    d_presolve_cache_wq.push_back( withinQuant );
-    d_presolve_cache_wic.push_back( withinInstClosure );
-  }else{
+  if( options::incrementalSolving() ){
+    if( d_presolve_in.find( n )==d_presolve_in.end() ){
+      d_presolve_in.insert( n );
+      d_presolve_cache.push_back( n );
+      d_presolve_cache_wq.push_back( withinQuant );
+      d_presolve_cache_wic.push_back( withinInstClosure );
+    }
+  }
+  //only wait if we are doing incremental solving
+  if( !d_presolve || !options::incrementalSolving() ){
     std::set< Node > added;
     getTermDatabase()->addTerm( n, added, withinQuant, withinInstClosure );
     //maybe have triggered instantiations if we are doing eager instantiation
index 4e3bba501af4764fc1732c90763766623f609b70..30c4dabdff07ed841bd2978f6921ddd53f3bb0a1 100644 (file)
@@ -29,6 +29,8 @@
 #include <ext/hash_set>
 #include <iostream>
 #include <map>
+#include "context/cdchunk_list.h"
+#include "context/cdhashset.h"
 
 namespace CVC4 {
 
@@ -113,8 +115,11 @@ class QuantifiersEngine {
   friend class quantifiers::RewriteEngine;
   friend class quantifiers::QuantConflictFind;
   friend class inst::InstMatch;
-private:
   typedef context::CDHashMap< Node, bool, NodeHashFunction > BoolMap;
+  typedef context::CDChunkList<Node> NodeList;
+  typedef context::CDChunkList<bool> BoolList;
+  typedef context::CDHashSet<Node, NodeHashFunction> NodeSet;
+private:
   /** reference to theory engine object */
   TheoryEngine* d_te;
   /** vector of modules for quantifiers */
@@ -197,9 +202,10 @@ private:
   /** has presolve been called */
   context::CDO< bool > d_presolve;
   /** presolve cache */
-  std::vector< Node > d_presolve_cache;
-  std::vector< bool > d_presolve_cache_wq;
-  std::vector< bool > d_presolve_cache_wic;
+  NodeSet d_presolve_in;
+  NodeList d_presolve_cache;
+  BoolList d_presolve_cache_wq;
+  BoolList d_presolve_cache_wic;
 private:
   KEEP_STATISTIC(TimerStat, d_time, "theory::QuantifiersEngine::time");
 public:
index 649cbee904f4e558542913ce9134e4515f534a50..6d50cc39f8f099fcb5c2ce7aa29de982963cb0bb 100644 (file)
@@ -42,7 +42,8 @@ BUG_TESTS = \
   quant-fun-proc-unfd.smt2 \
   bug654-dd.smt2 \
   bug-fmf-fun-skolem.smt2 \
-  bug674.smt2
+  bug674.smt2 \
+  inc-double-u.smt2
 
 TESTS =        $(SMT_TESTS) $(SMT2_TESTS) $(CVC_TESTS) $(BUG_TESTS)
 
diff --git a/test/regress/regress0/push-pop/inc-double-u.smt2 b/test/regress/regress0/push-pop/inc-double-u.smt2
new file mode 100644 (file)
index 0000000..a01643d
--- /dev/null
@@ -0,0 +1,16 @@
+; COMMAND-LINE: --incremental 
+(set-logic UFLIA)
+(declare-fun P (Int) Bool)
+(declare-fun R (Int) Bool)
+(assert (forall ((x Int)) (=> (R x) (not (P x)))))
+; EXPECT: unknown
+(check-sat)
+(assert (R 0))
+; EXPECT: unknown
+(check-sat)
+(assert (forall ((x Int)) (P x)))
+; EXPECT: unsat
+(check-sat)
+(push 1)
+; EXPECT: unsat
+(check-sat)
index 716d413656a694be965cb00b720edc638b2f3e84..09dbdf08f09517f866a23a666c81b58f0c57d43c 100644 (file)
@@ -58,7 +58,8 @@ TESTS = \
   bug613.smt2 \
   idof-triv.smt2 \
   chapman150408.smt2 \
-  pierre150331.smt2
+  pierre150331.smt2 \
+  norn-360.smt2
 
 FAILING_TESTS =
 
diff --git a/test/regress/regress0/strings/norn-360.smt2 b/test/regress/regress0/strings/norn-360.smt2
new file mode 100644 (file)
index 0000000..573dcbe
--- /dev/null
@@ -0,0 +1,25 @@
+(set-logic QF_SLIA)
+(set-option :strings-exp true)
+(set-info :status sat)
+
+(declare-fun var_0 () String)
+(declare-fun var_1 () String)
+(declare-fun var_2 () String)
+(declare-fun var_3 () String)
+(declare-fun var_4 () String)
+(declare-fun var_5 () String)
+(declare-fun var_6 () String)
+(declare-fun var_7 () String)
+(declare-fun var_8 () String)
+(declare-fun var_9 () String)
+(declare-fun var_10 () String)
+(declare-fun var_11 () String)
+(declare-fun var_12 () String)
+
+(assert (str.in.re (str.++ var_3 "z" var_4 ) (re.++ (re.* (re.union (re.union (str.to.re "z") (str.to.re "b")) (re.++ (str.to.re "a") (re.union (re.union (str.to.re "z") (str.to.re "b")) (str.to.re "a"))))) (str.to.re "a"))))
+(assert (str.in.re (str.++ var_3 "z" var_4 ) (re.++ (re.* (re.union (re.union (str.to.re "z") (str.to.re "b")) (re.++ (str.to.re "a") (re.union (str.to.re "z") (str.to.re "a"))))) (str.to.re "a"))))
+(assert (str.in.re (str.++ var_3 "z" var_4 ) (re.++ (re.* (re.union (str.to.re "z") (re.++ (re.union (str.to.re "b") (str.to.re "a")) (re.union (str.to.re "z") (str.to.re "b"))))) (re.union (str.to.re "b") (str.to.re "a")))))
+(assert (str.in.re var_4 (re.* (re.range "a" "u"))))
+(assert (str.in.re var_3 (re.* (re.range "a" "u"))))
+(assert (<= 0  (str.len var_4)))
+(check-sat)
\ No newline at end of file