SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
BVModule.h
Go to the documentation of this file.
1 /*
2  * SMT-RAT - Satisfiability-Modulo-Theories Real Algebra Toolbox
3  * Copyright (C) 2012 Florian Corzilius, Ulrich Loup, Erika Abraham, Sebastian Junges
4  *
5  * This file is part of SMT-RAT.
6  *
7  * SMT-RAT is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * SMT-RAT is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with SMT-RAT. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 /**
22  * @file BVModule.h
23  * @author YOUR NAME <YOUR EMAIL ADDRESS>
24  *
25  * @version 2015-02-05
26  * Created on 2015-02-05.
27  */
28 
29 #pragma once
30 
31 #include <smtrat-solver/Module.h>
32 #include "BVSettings.h"
33 #include "BVDirectEncoder.h"
34 #include "carl-formula/bitvector/BVConstraint.h"
35 #include "carl-formula/bitvector/BVConstraintPool.h"
36 
37 namespace smtrat
38 {
39  template<typename Settings>
40  class BVModule : public Module
41  {
42  private:
43  ///
44  mutable bool mModelComputed;
45  ///
47  ///
48  std::unordered_set<FormulaT> mBlastedFormulas;
49  ///
50  std::unordered_map<FormulaT,std::map<std::pair<size_t,size_t>,FormulaT>::iterator> mPositionInFormulasToBlast;
51  ///
52  std::map<std::pair<size_t,size_t>,FormulaT> mFormulasToBlast;
53 
54  public:
56  std::string moduleName() const {
57  return SettingsType::moduleName;
58  }
59  BVModule( const ModuleInput* _formula, Conditionals& _conditionals, Manager* _manager = NULL );
60 
62 
63  // Main interfaces.
64 
65  /**
66  * Informs the module about the given constraint. It should be tried to inform this
67  * module about any constraint it could receive eventually before assertSubformula
68  * is called (preferably for the first time, but at least before adding a formula
69  * containing that constraint).
70  * @param _constraint The constraint to inform about.
71  * @return false, if it can be easily decided whether the given constraint is inconsistent;
72  * true, otherwise.
73  */
74  bool informCore( const FormulaT& _constraint );
75 
76  /**
77  * Informs all backends about the so far encountered constraints, which have not yet been communicated.
78  * This method must not and will not be called more than once and only before the first runBackends call.
79  */
80  void init();
81 
82  /**
83  * The module has to take the given sub-formula of the received formula into account.
84  *
85  * @param _subformula The sub-formula to take additionally into account.
86  * @return false, if it can be easily decided that this sub-formula causes a conflict with
87  * the already considered sub-formulas;
88  * true, otherwise.
89  */
90  bool addCore( ModuleInput::const_iterator _subformula );
91 
92  /**
93  * Removes the subformula of the received formula at the given position to the considered ones of this module.
94  * Note that this includes every stored calculation which depended on this subformula, but should keep the other
95  * stored calculation, if possible, untouched.
96  *
97  * @param _subformula The position of the subformula to remove.
98  */
100 
101  /**
102  * Updates the current assignment into the model.
103  * Note, that this is a unique but possibly symbolic assignment maybe containing newly introduced variables.
104  */
105  void updateModel() const;
106 
107  /**
108  * Checks the received formula for consistency.
109  * @return SAT, if the received formula is satisfiable;
110  * UNSAT, if the received formula is not satisfiable;
111  * Unknown, otherwise.
112  */
114 
115  protected:
116 
117  size_t evaluateBVFormula( const FormulaT& formula );
118 
119  void transferBackendModel() const;
120  };
121 }
size_t evaluateBVFormula(const FormulaT &formula)
bool addCore(ModuleInput::const_iterator _subformula)
The module has to take the given sub-formula of the received formula into account.
void init()
Informs all backends about the so far encountered constraints, which have not yet been communicated.
Settings SettingsType
Definition: BVModule.h:55
void transferBackendModel() const
bool mModelComputed
Definition: BVModule.h:44
std::map< std::pair< size_t, size_t >, FormulaT > mFormulasToBlast
Definition: BVModule.h:52
bool informCore(const FormulaT &_constraint)
Informs the module about the given constraint.
void removeCore(ModuleInput::const_iterator _subformula)
Removes the subformula of the received formula at the given position to the considered ones of this m...
Answer checkCore()
Checks the received formula for consistency.
BVModule(const ModuleInput *_formula, Conditionals &_conditionals, Manager *_manager=NULL)
std::unordered_map< FormulaT, std::map< std::pair< size_t, size_t >, FormulaT >::iterator > mPositionInFormulasToBlast
Definition: BVModule.h:50
std::string moduleName() const
Definition: BVModule.h:56
void updateModel() const
Updates the current assignment into the model.
std::unordered_set< FormulaT > mBlastedFormulas
Definition: BVModule.h:48
BVDirectEncoder mEncoder
Definition: BVModule.h:46
Base class for solvers.
Definition: Manager.h:34
The input formula a module has to consider for it's satisfiability check.
Definition: ModuleInput.h:131
super::const_iterator const_iterator
Passing through the list::const_iterator.
Definition: ModuleInput.h:146
A base class for all kind of theory solving methods.
Definition: Module.h:70
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
Definition: types.h:37
const settings::Settings & Settings()
Definition: Settings.h:96
Answer
An enum with the possible answers a Module can give.
Definition: types.h:57
std::vector< std::atomic_bool * > Conditionals
A vector of atomic bool pointers.
Definition: types.h:17