summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHaniel Barbosa <hanielbbarbosa@gmail.com>2018-08-16 16:15:07 -0500
committerAndrew Reynolds <andrew.j.reynolds@gmail.com>2018-08-16 16:15:07 -0500
commit0e77d62ac116c00bcb0bccdb1f48f87067529d56 (patch)
treef28ee420eef68eff771446c246829ee4acb0c15e /src
parent80be200c84494a4f82ab30cb743b7758c67db5b5 (diff)
Refactor extended rewriter preprocessing pass (#2324)
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am2
-rw-r--r--src/preprocessing/passes/extended_rewriter_pass.cpp42
-rw-r--r--src/preprocessing/passes/extended_rewriter_pass.h43
-rw-r--r--src/smt/smt_engine.cpp13
4 files changed, 93 insertions, 7 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index c7dc311b6..992f229d6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -73,6 +73,8 @@ libcvc4_la_SOURCES = \
preprocessing/passes/bv_gauss.h \
preprocessing/passes/bv_intro_pow2.cpp \
preprocessing/passes/bv_intro_pow2.h \
+ preprocessing/passes/extended_rewriter_pass.cpp \
+ preprocessing/passes/extended_rewriter_pass.h \
preprocessing/passes/int_to_bv.cpp \
preprocessing/passes/int_to_bv.h \
preprocessing/passes/pseudo_boolean_processor.cpp \
diff --git a/src/preprocessing/passes/extended_rewriter_pass.cpp b/src/preprocessing/passes/extended_rewriter_pass.cpp
new file mode 100644
index 000000000..572aaed7a
--- /dev/null
+++ b/src/preprocessing/passes/extended_rewriter_pass.cpp
@@ -0,0 +1,42 @@
+/********************* */
+/*! \file extended_rewriter_pass.cpp
+ ** \verbatim
+ ** Top contributors (to current version):
+ ** Haniel Barbosa
+ ** 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 The ExtRewPre preprocessing pass
+ **
+ ** Applies the extended rewriter to assertions
+ **/
+
+#include "preprocessing/passes/extended_rewriter_pass.h"
+
+#include "theory/quantifiers/extended_rewrite.h"
+
+namespace CVC4 {
+namespace preprocessing {
+namespace passes {
+
+ExtRewPre::ExtRewPre(PreprocessingPassContext* preprocContext)
+ : PreprocessingPass(preprocContext, "ext-rew-pre"){};
+
+PreprocessingPassResult ExtRewPre::applyInternal(
+ AssertionPipeline* assertionsToPreprocess)
+{
+ theory::quantifiers::ExtendedRewriter extr(options::extRewPrepAgg());
+ for (unsigned i = 0, size = assertionsToPreprocess->size(); i < size; ++i)
+ {
+ assertionsToPreprocess->replace(
+ i, extr.extendedRewrite((*assertionsToPreprocess)[i]));
+ }
+ return PreprocessingPassResult::NO_CONFLICT;
+}
+
+} // namespace passes
+} // namespace preprocessing
+} // namespace CVC4
diff --git a/src/preprocessing/passes/extended_rewriter_pass.h b/src/preprocessing/passes/extended_rewriter_pass.h
new file mode 100644
index 000000000..f604a1af5
--- /dev/null
+++ b/src/preprocessing/passes/extended_rewriter_pass.h
@@ -0,0 +1,43 @@
+/********************* */
+/*! \file extended_rewriter_pass.h
+ ** \verbatim
+ ** Top contributors (to current version):
+ ** Haniel Barbosa
+ ** 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 The ExtRewPre preprocessing pass
+ **
+ ** Applies the extended rewriter to assertions
+ **/
+
+#include "cvc4_private.h"
+
+#ifndef __CVC4__PREPROCESSING__PASSES__EXTENDED_REWRITER_PASS_H
+#define __CVC4__PREPROCESSING__PASSES__EXTENDED_REWRITER_PASS_H
+
+#include "preprocessing/preprocessing_pass.h"
+#include "preprocessing/preprocessing_pass_context.h"
+
+namespace CVC4 {
+namespace preprocessing {
+namespace passes {
+
+class ExtRewPre : public PreprocessingPass
+{
+ public:
+ ExtRewPre(PreprocessingPassContext* preprocContext);
+
+ protected:
+ PreprocessingPassResult applyInternal(
+ AssertionPipeline* assertionsToPreprocess) override;
+};
+
+} // namespace passes
+} // namespace preprocessing
+} // namespace CVC4
+
+#endif /* __CVC4__PREPROCESSING__PASSES__EXTENDED_REWRITER_PASS_H */
diff --git a/src/smt/smt_engine.cpp b/src/smt/smt_engine.cpp
index 41b113b94..b5d758bca 100644
--- a/src/smt/smt_engine.cpp
+++ b/src/smt/smt_engine.cpp
@@ -77,6 +77,7 @@
#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"
@@ -2672,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(
@@ -2704,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));
@@ -4156,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);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback