diff options
author | Mathias Preiner <mathias.preiner@gmail.com> | 2018-08-30 15:49:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-30 15:49:45 -0700 |
commit | 45af307478241b1fc8278406549d297f7f80fdb3 (patch) | |
tree | d8dcfcfb1e0599b6a8bfc5cb81ac9461891be215 /src/preprocessing/passes | |
parent | 6d04d6daff575a7e48eb88124faefadfadf727f4 (diff) |
Refactor theory preprocess into preprocessing pass. (#2395)
Diffstat (limited to 'src/preprocessing/passes')
-rw-r--r-- | src/preprocessing/passes/theory_preprocess.cpp | 49 | ||||
-rw-r--r-- | src/preprocessing/passes/theory_preprocess.h | 43 |
2 files changed, 92 insertions, 0 deletions
diff --git a/src/preprocessing/passes/theory_preprocess.cpp b/src/preprocessing/passes/theory_preprocess.cpp new file mode 100644 index 000000000..edb0fc800 --- /dev/null +++ b/src/preprocessing/passes/theory_preprocess.cpp @@ -0,0 +1,49 @@ +/********************* */ +/*! \file bv_abstraction.cpp + ** \verbatim + ** Top contributors (to current version): + ** Mathias Preiner + ** 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 TheoryPreprocess preprocessing pass + ** + ** Calls Theory::preprocess(...) on every assertion of the formula. + **/ + +#include "preprocessing/passes/theory_preprocess.h" + +#include "theory/rewriter.h" +#include "theory/theory_engine.h" + +namespace CVC4 { +namespace preprocessing { +namespace passes { + +using namespace CVC4::theory; + +TheoryPreprocess::TheoryPreprocess(PreprocessingPassContext* preprocContext) + : PreprocessingPass(preprocContext, "theory-preprocess"){}; + +PreprocessingPassResult TheoryPreprocess::applyInternal( + AssertionPipeline* assertionsToPreprocess) +{ + TheoryEngine* te = d_preprocContext->getTheoryEngine(); + te->preprocessStart(); + for (size_t i = 0, size = assertionsToPreprocess->size(); i < size; ++i) + { + TNode a = (*assertionsToPreprocess)[i]; + Assert(Rewriter::rewrite(a) == a); + assertionsToPreprocess->replace(i, te->preprocess(a)); + a = (*assertionsToPreprocess)[i]; + Assert(Rewriter::rewrite(a) == a); + } + return PreprocessingPassResult::NO_CONFLICT; +} + +} // namespace passes +} // namespace preprocessing +} // namespace CVC4 diff --git a/src/preprocessing/passes/theory_preprocess.h b/src/preprocessing/passes/theory_preprocess.h new file mode 100644 index 000000000..58eaee611 --- /dev/null +++ b/src/preprocessing/passes/theory_preprocess.h @@ -0,0 +1,43 @@ +/********************* */ +/*! \file theory_preprocess.h + ** \verbatim + ** Top contributors (to current version): + ** Mathias Preiner + ** 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 TheoryPreprocess preprocessing pass + ** + ** Calls Theory::preprocess(...) on every assertion of the formula. + **/ + +#include "cvc4_private.h" + +#ifndef __CVC4__PREPROCESSING__PASSES__THEORY_PREPROCESS_H +#define __CVC4__PREPROCESSING__PASSES__THEORY_PREPROCESS_H + +#include "preprocessing/preprocessing_pass.h" +#include "preprocessing/preprocessing_pass_context.h" + +namespace CVC4 { +namespace preprocessing { +namespace passes { + +class TheoryPreprocess : public PreprocessingPass +{ + public: + TheoryPreprocess(PreprocessingPassContext* preprocContext); + + protected: + PreprocessingPassResult applyInternal( + AssertionPipeline* assertionsToPreprocess) override; +}; + +} // namespace passes +} // namespace preprocessing +} // namespace CVC4 + +#endif /* __CVC4__PREPROCESSING__PASSES__THEORY_PREPROCESS_H */ |