SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
NewCADModule.h
Go to the documentation of this file.
1 /**
2  * @file NewCADModule.h
3  * @author YOUR NAME <YOUR EMAIL ADDRESS>
4  *
5  * @version 2016-02-23
6  * Created on 2016-02-23.
7  */
8 
9 #pragma once
10 
11 #include <smtrat-cad/CAD.h>
12 //#include <smtrat-cad/utils/CADPreprocessor.h>
15 
16 #include <smtrat-solver/Module.h>
17 #include "NewCADStatistics.h"
18 #include "NewCADSettings.h"
19 
20 namespace smtrat
21 {
22  template<typename Settings>
23  class NewCADModule : public Module
24  {
25  private:
26 #ifdef SMTRAT_DEVOPTION_Statistics
27  NewCADStatistics& mStatistics = statistics_get<NewCADStatistics>(Settings::moduleName);
28 #endif
29  /// Stores the polynomials seen during inform() to build the variable ordering.
30  std::vector<Poly> mPolynomials;
31 
32  carl::carlVariables mVariables;
36 
38 
39  void addConstraint(const ConstraintT& c) {
41  }
42  void removeConstraint(const ConstraintT& c) {
44  }
46  for (const auto& f: rReceivedFormula()) {
47  assert(f.formula().type() == carl::FormulaType::CONSTRAINT);
48  addConstraint(f.formula().constraint());
49  }
50  }
52  //while (!mPreprocessor.inequalities().empty()) {
53  // mPreprocessor.removeConstraint(mPreprocessor.inequalities().begin()->first);
54  //}
55  //while (!mPreprocessor.equalities().empty()) {
56  // mPreprocessor.removeConstraint(mPreprocessor.equalities().front());
57  //}
58  //mPreprocessor.preprocess();
60  }
61 
62  public:
64  std::string moduleName() const {
65  return SettingsType::moduleName;
66  }
67  NewCADModule(const ModuleInput* _formula, Conditionals& _conditionals, Manager* _manager = nullptr);
68 
70 
71  // Main interfaces.
72  /**
73  * Informs the module about the given constraint. It should be tried to inform this
74  * module about any constraint it could receive eventually before assertSubformula
75  * is called (preferably for the first time, but at least before adding a formula
76  * containing that constraint).
77  * @param _constraint The constraint to inform about.
78  * @return false, if it can be easily decided whether the given constraint is inconsistent;
79  * true, otherwise.
80  */
81  bool informCore( const FormulaT& _constraint );
82 
83  /**
84  * Informs all backends about the so far encountered constraints, which have not yet been communicated.
85  * This method must not and will not be called more than once and only before the first runBackends call.
86  */
87  void init();
88 
89  /**
90  * The module has to take the given sub-formula of the received formula into account.
91  *
92  * @param _subformula The sub-formula to take additionally into account.
93  * @return false, if it can be easily decided that this sub-formula causes a conflict with
94  * the already considered sub-formulas;
95  * true, otherwise.
96  */
97  bool addCore( ModuleInput::const_iterator _subformula );
98 
99  /**
100  * Removes the subformula of the received formula at the given position to the considered ones of this module.
101  * Note that this includes every stored calculation which depended on this subformula, but should keep the other
102  * stored calculation, if possible, untouched.
103  *
104  * @param _subformula The position of the subformula to remove.
105  */
107 
108  /**
109  * Updates the current assignment into the model.
110  * Note, that this is a unique but possibly symbolic assignment maybe containing newly introduced variables.
111  */
112  void updateModel() const;
113 
114  /**
115  * Checks the received formula for consistency.
116  * @param _full false, if this module should avoid too expensive procedures and rather return unknown instead.
117  * @param _objective if not set to NO_VARIABLE, the module should find an assignment minimizing this objective variable; otherwise any assignment is good.
118  * @return True, if the received formula is satisfiable;
119  * False, if the received formula is not satisfiable;
120  * Unknown, otherwise.
121  */
123  };
124 }
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
ModuleStatistics & mStatistics
Definition: Module.h:192
const ModuleInput & rReceivedFormula() const
Definition: Module.h:439
NewCADModule(const ModuleInput *_formula, Conditionals &_conditionals, Manager *_manager=nullptr)
std::vector< Poly > mPolynomials
Stores the polynomials seen during inform() to build the variable ordering.
Definition: NewCADModule.h:30
std::string moduleName() const
Definition: NewCADModule.h:64
bool informCore(const FormulaT &_constraint)
Informs the module about the given constraint.
Answer checkCore()
Checks the received formula for consistency.
carl::carlVariables mVariables
Definition: NewCADModule.h:32
void removeConstraint(const ConstraintT &c)
Definition: NewCADModule.h:42
cad::CAD< Settings > mCAD
Definition: NewCADModule.h:33
void pushConstraintsToReplacer()
Definition: NewCADModule.h:45
void removeConstraintsFromReplacer()
Definition: NewCADModule.h:51
void addConstraint(const ConstraintT &c)
Definition: NewCADModule.h:39
void removeCore(ModuleInput::const_iterator _subformula)
Removes the subformula of the received formula at the given position to the considered ones of this m...
void init()
Informs all backends about the so far encountered constraints, which have not yet been communicated.
cad::Assignment mLastAssignment
Definition: NewCADModule.h:34
bool addCore(ModuleInput::const_iterator _subformula)
The module has to take the given sub-formula of the received formula into account.
cad::Preprocessor mPreprocessor
Definition: NewCADModule.h:37
void updateModel() const
Updates the current assignment into the model.
void addConstraint(const ConstraintT &c)
void removeConstraint(const ConstraintT &c)
std::map< carl::Variable, RAN > Assignment
Definition: common.h:14
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
Definition: types.h:37
const settings::Settings & Settings()
Definition: Settings.h:96
carl::Model< Rational, Poly > Model
Definition: model.h:13
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
carl::Constraint< Poly > ConstraintT
Definition: types.h:29