diff options
author | Mathias Preiner <mathias.preiner@gmail.com> | 2018-08-16 23:07:49 -0700 |
---|---|---|
committer | Andres Noetzli <andres.noetzli@gmail.com> | 2018-08-16 23:07:49 -0700 |
commit | 420f25b1c8103bec7d5fd63a8ade2d9373395e55 (patch) | |
tree | 353bb0635d2f5d0f6fdca69b1dac96a16404de3f /src/preprocessing | |
parent | 7181344be7b4f723ded3fae8d9b269ffc401caa4 (diff) |
Refactor eager atoms preprocessing pass. (#2318)
Diffstat (limited to 'src/preprocessing')
-rw-r--r-- | src/preprocessing/passes/bv_eager_atoms.cpp | 47 | ||||
-rw-r--r-- | src/preprocessing/passes/bv_eager_atoms.h | 44 |
2 files changed, 91 insertions, 0 deletions
diff --git a/src/preprocessing/passes/bv_eager_atoms.cpp b/src/preprocessing/passes/bv_eager_atoms.cpp new file mode 100644 index 000000000..fe43ebcd0 --- /dev/null +++ b/src/preprocessing/passes/bv_eager_atoms.cpp @@ -0,0 +1,47 @@ +/********************* */ +/*! \file bv_eager_atoms.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 Wrap assertions in BITVECTOR_EAGER_ATOM nodes. + ** + ** This preprocessing pass wraps all assertions in BITVECTOR_EAGER_ATOM nodes + ** and allows to use eager bit-blasting in the BV solver. + **/ + + +#include "preprocessing/passes/bv_eager_atoms.h" + +#include "theory/theory_model.h" + +namespace CVC4 { +namespace preprocessing { +namespace passes { + +BvEagerAtoms::BvEagerAtoms(PreprocessingPassContext* preprocContext) + : PreprocessingPass(preprocContext, "bv-eager-atoms"){}; + +PreprocessingPassResult BvEagerAtoms::applyInternal( + AssertionPipeline* assertionsToPreprocess) +{ + theory::TheoryModel* tm = d_preprocContext->getTheoryEngine()->getModel(); + NodeManager* nm = NodeManager::currentNM(); + for (unsigned i = 0, size = assertionsToPreprocess->size(); i < size; ++i) + { + TNode atom = (*assertionsToPreprocess)[i]; + Node eager_atom = nm->mkNode(kind::BITVECTOR_EAGER_ATOM, atom); + tm->addSubstitution(eager_atom, atom); + assertionsToPreprocess->replace(i, eager_atom); + } + return PreprocessingPassResult::NO_CONFLICT; +} + +} // namespace passes +} // namespace preprocessing +} // namespace CVC4 diff --git a/src/preprocessing/passes/bv_eager_atoms.h b/src/preprocessing/passes/bv_eager_atoms.h new file mode 100644 index 000000000..585c108fc --- /dev/null +++ b/src/preprocessing/passes/bv_eager_atoms.h @@ -0,0 +1,44 @@ +/********************* */ +/*! \file bv_eager_atoms.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 Wrap assertions in BITVECTOR_EAGER_ATOM nodes. + ** + ** This preprocessing pass wraps all assertions in BITVECTOR_EAGER_ATOM nodes + ** and allows to use eager bit-blasting in the BV solver. + **/ + +#include "cvc4_private.h" + +#ifndef __CVC4__PREPROCESSING__PASSES__BV_EAGER_ATOMS_H +#define __CVC4__PREPROCESSING__PASSES__BV_EAGER_ATOMS_H + +#include "preprocessing/preprocessing_pass.h" +#include "preprocessing/preprocessing_pass_context.h" + +namespace CVC4 { +namespace preprocessing { +namespace passes { + +class BvEagerAtoms : public PreprocessingPass +{ + public: + BvEagerAtoms(PreprocessingPassContext* preprocContext); + + protected: + PreprocessingPassResult applyInternal( + AssertionPipeline* assertionsToPreprocess) override; +}; + +} // namespace passes +} // namespace preprocessing +} // namespace CVC4 + +#endif /* __CVC4__PREPROCESSING__PASSES__BV_EAGER_ATOMS_H */ |