diff options
Diffstat (limited to 'src/smt/smt_engine.cpp')
-rw-r--r-- | src/smt/smt_engine.cpp | 82 |
1 files changed, 12 insertions, 70 deletions
diff --git a/src/smt/smt_engine.cpp b/src/smt/smt_engine.cpp index db4efe89f..b5d758bca 100644 --- a/src/smt/smt_engine.cpp +++ b/src/smt/smt_engine.cpp @@ -70,12 +70,14 @@ #include "options/theory_options.h" #include "options/uf_options.h" #include "preprocessing/passes/apply_substs.h" +#include "preprocessing/passes/apply_to_const.h" #include "preprocessing/passes/bool_to_bv.h" #include "preprocessing/passes/bv_abstraction.h" #include "preprocessing/passes/bv_ackermann.h" #include "preprocessing/passes/bv_gauss.h" #include "preprocessing/passes/bv_intro_pow2.h" #include "preprocessing/passes/bv_to_bool.h" +#include "preprocessing/passes/extended_rewriter_pass.h" #include "preprocessing/passes/int_to_bv.h" #include "preprocessing/passes/pseudo_boolean_processor.h" #include "preprocessing/passes/real_to_int.h" @@ -897,66 +899,6 @@ public: return retval; } - NodeToNodeHashMap d_rewriteApplyToConstCache; - Node rewriteApplyToConst(TNode n) { - Trace("rewriteApplyToConst") << "rewriteApplyToConst :: " << n << std::endl; - - if(n.getMetaKind() == kind::metakind::CONSTANT || - n.getMetaKind() == kind::metakind::VARIABLE || - n.getMetaKind() == kind::metakind::NULLARY_OPERATOR) - { - return n; - } - - if(d_rewriteApplyToConstCache.find(n) != d_rewriteApplyToConstCache.end()) { - Trace("rewriteApplyToConst") << "in cache :: " - << d_rewriteApplyToConstCache[n] - << std::endl; - return d_rewriteApplyToConstCache[n]; - } - - if(n.getKind() == kind::APPLY_UF) { - if(n.getNumChildren() == 1 && n[0].isConst() && - n[0].getType().isInteger()) - { - stringstream ss; - ss << n.getOperator() << "_"; - if(n[0].getConst<Rational>() < 0) { - ss << "m" << -n[0].getConst<Rational>(); - } else { - ss << n[0]; - } - Node newvar = NodeManager::currentNM()->mkSkolem( - ss.str(), n.getType(), "rewriteApplyToConst skolem", - NodeManager::SKOLEM_EXACT_NAME); - d_rewriteApplyToConstCache[n] = newvar; - Trace("rewriteApplyToConst") << "made :: " << newvar << std::endl; - return newvar; - } else { - stringstream ss; - ss << "The rewrite-apply-to-const preprocessor is currently limited;" - << std::endl - << "it only works if all function symbols are unary and with Integer" - << std::endl - << "domain, and all applications are to integer values." << std::endl - << "Found application: " << n; - Unhandled(ss.str()); - } - } - - NodeBuilder<> builder(n.getKind()); - if(n.getMetaKind() == kind::metakind::PARAMETERIZED) { - builder << n.getOperator(); - } - for(unsigned i = 0; i < n.getNumChildren(); ++i) { - builder << rewriteApplyToConst(n[i]); - } - Node rewr = builder; - d_rewriteApplyToConstCache[n] = rewr; - Trace("rewriteApplyToConst") << "built :: " << rewr << std::endl; - return rewr; - } - void addUseTheoryListListener(TheoryEngine* theoryEngine){ Options& nodeManagerOptions = NodeManager::currentNM()->getOptions(); d_listenerRegistrations->add( @@ -2717,6 +2659,8 @@ void SmtEnginePrivate::finishInit() // actually assembling preprocessing pipelines). std::unique_ptr<ApplySubsts> applySubsts( new ApplySubsts(d_preprocessingPassContext.get())); + std::unique_ptr<ApplyToConst> applyToConst( + new ApplyToConst(d_preprocessingPassContext.get())); std::unique_ptr<BoolToBV> boolToBv( new BoolToBV(d_preprocessingPassContext.get())); std::unique_ptr<BvAbstraction> bvAbstract( @@ -2729,6 +2673,8 @@ void SmtEnginePrivate::finishInit() new BvIntroPow2(d_preprocessingPassContext.get())); std::unique_ptr<BVToBool> bvToBool( new BVToBool(d_preprocessingPassContext.get())); + std::unique_ptr<ExtRewPre> extRewPre( + new ExtRewPre(d_preprocessingPassContext.get())); std::unique_ptr<IntToBV> intToBV( new IntToBV(d_preprocessingPassContext.get())); std::unique_ptr<PseudoBooleanProcessor> pbProc( @@ -2750,6 +2696,8 @@ void SmtEnginePrivate::finishInit() new SepSkolemEmp(d_preprocessingPassContext.get())); d_preprocessingPassRegistry.registerPass("apply-substs", std::move(applySubsts)); + d_preprocessingPassRegistry.registerPass("apply-to-const", + std::move(applyToConst)); d_preprocessingPassRegistry.registerPass("bool-to-bv", std::move(boolToBv)); d_preprocessingPassRegistry.registerPass("bv-abstraction", std::move(bvAbstract)); @@ -2759,6 +2707,7 @@ void SmtEnginePrivate::finishInit() d_preprocessingPassRegistry.registerPass("bv-intro-pow2", std::move(bvIntroPow2)); d_preprocessingPassRegistry.registerPass("bv-to-bool", std::move(bvToBool)); + d_preprocessingPassRegistry.registerPass("ext-rew-pre", std::move(extRewPre)); d_preprocessingPassRegistry.registerPass("int-to-bv", std::move(intToBV)); d_preprocessingPassRegistry.registerPass("pseudo-boolean-processor", std::move(pbProc)); @@ -4211,19 +4160,14 @@ void SmtEnginePrivate::processAssertions() { if (options::extRewPrep()) { - theory::quantifiers::ExtendedRewriter extr(options::extRewPrepAgg()); - for (unsigned i = 0; i < d_assertions.size(); ++i) - { - Node a = d_assertions[i]; - d_assertions.replace(i, extr.extendedRewrite(a)); - } + d_preprocessingPassRegistry.getPass("ext-rew-pre")->apply(&d_assertions); } // Unconstrained simplification if(options::unconstrainedSimp()) { Trace("smt-proc") << "SmtEnginePrivate::processAssertions() : pre-unconstrained-simp" << endl; dumpAssertions("pre-unconstrained-simp", d_assertions); - d_preprocessingPassRegistry.getPass("rewrite")->apply(&d_assertions); + d_preprocessingPassRegistry.getPass("rewrite")->apply(&d_assertions); unconstrainedSimp(); Trace("smt-proc") << "SmtEnginePrivate::processAssertions() : post-unconstrained-simp" << endl; dumpAssertions("post-unconstrained-simp", d_assertions); @@ -4476,9 +4420,7 @@ void SmtEnginePrivate::processAssertions() { if(options::rewriteApplyToConst()) { Chat() << "Rewriting applies to constants..." << endl; TimerStat::CodeTimer codeTimer(d_smt.d_stats->d_rewriteApplyToConstTime); - for (unsigned i = 0; i < d_assertions.size(); ++ i) { - d_assertions[i] = Rewriter::rewrite(rewriteApplyToConst(d_assertions[i])); - } + d_preprocessingPassRegistry.getPass("apply-to-const")->apply(&d_assertions); } dumpAssertions("post-rewrite-apply-to-const", d_assertions); |