SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
PModule.h
Go to the documentation of this file.
1 /**
2  * All preprocessing modules shall derive from this module, that is modules, which simplify
3  * their received formula to an equisatisfiable formula being passed to their backends.
4  *
5  * @file PModule.h
6  * @author Florian Corzilius <corzilius@cs.rwth-aachen.de>
7  *
8  * @version 2015-09-09
9  * Created on 2015-09-09.
10  */
11 
12 #pragma once
13 
14 #include "Module.h"
15 
16 namespace smtrat
17 {
18  class PModule : public Module
19  {
20  private:
21  bool mAppliedPreprocessing = false;
22  std::pair<bool,FormulaT> mSimplifiedFormula;
23 
25  public:
26 
27  PModule( const ModuleInput* _formula, Conditionals& _foundAnswer, Manager* _manager = nullptr, std::string module_name = "PModule" );
28 
29  /**
30  * @return true, if this module is a preprocessor that is a module, which simplifies
31  * its received formula to an equisatisfiable formula being passed to its backends.
32  * The simplified formula can be obtained with getReceivedFormulaSimplified().
33  */
34  bool isPreprocessor() const
35  {
36  return false;
37  }
38 
39  /**
40  * @return true, if the current received formula has been simplified and the result of this simplification
41  * is stored in the passed formula.
42  */
43  bool appliedPreprocessing() const
44  {
45  return mAppliedPreprocessing;
46  }
47 
48  /**
49  * The module has to take the given sub-formula of the received formula into account.
50  *
51  * @param _subformula The sub-formula to take additionally into account.
52  * @return false, if it can be easily decided that this sub-formula causes a conflict with
53  * the already considered sub-formulas;
54  * true, otherwise.
55  */
56  bool add( ModuleInput::const_iterator _subformula );
57 
58  /**
59  * Removes everything related to the given sub-formula of the received formula. However,
60  * it is desired not to lose track of search spaces where no satisfying assignment can
61  * be found for the remaining sub-formulas.
62  *
63  * @param _subformula The sub formula of the received formula to remove.
64  */
65  void remove( ModuleInput::const_iterator _subformula );
66 
67  Answer check( bool _final = false, bool _full = true, carl::Variable _objective = carl::Variable::NO_VARIABLE );
68 
69  /**
70  * Runs the backend solvers on the passed formula.
71  * @param _final true, if this satisfiability check will be the last one (for a global sat-check), if its result is SAT.
72  * @param _full false, if this module should avoid too expensive procedures and rather return unknown instead.
73  * @param _objective if not set to NO_VARIABLE, the module should find an assignment minimizing this objective variable; otherwise any assignment is good.
74  * @return True, if the passed formula is consistent;
75  * False, if the passed formula is inconsistent;
76  * Unknown, otherwise.
77  */
78  Answer runBackends( bool _final, bool _full, carl::Variable _objective );
79 
80  virtual Answer runBackends() {
81  return PModule::runBackends( false /* mFinalCheck */, true /* mFullCheck */, mObjectiveVariable );
82  }
83 
84  /**
85  * @return A pair of a Boolean and a formula, where the Boolean is true, if the received formula
86  * could be simplified to an equisatisfiable formula. The formula is equisatisfiable to this
87  * module's reveived formula, if the Boolean is true.
88  */
89  std::pair<bool,FormulaT> getReceivedFormulaSimplified();
90 
91  /**
92  * Updates the current assignment into the model.
93  * Note, that this is a unique but possibly symbolic assignment maybe containing newly introduced variables.
94  */
95  void updateModel() const;
96  };
97 }
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
carl::Variable mObjectiveVariable
Objective variable to be minimized. If set to NO_VARIABLE, a normal sat check should be performed.
Definition: Module.h:209
PModule(const ModuleInput *_formula, Conditionals &_foundAnswer, Manager *_manager=nullptr, std::string module_name="PModule")
Definition: PModule.cpp:13
void remove(ModuleInput::const_iterator _subformula)
Removes everything related to the given sub-formula of the received formula.
Definition: PModule.cpp:50
virtual Answer runBackends()
Definition: PModule.h:80
std::pair< bool, FormulaT > mSimplifiedFormula
Definition: PModule.h:22
bool add(ModuleInput::const_iterator _subformula)
The module has to take the given sub-formula of the received formula into account.
Definition: PModule.cpp:44
bool appliedPreprocessing() const
Definition: PModule.h:43
void updateModel() const
Updates the current assignment into the model.
Definition: PModule.cpp:75
void collectSimplifiedFormula()
Definition: PModule.cpp:18
std::pair< bool, FormulaT > getReceivedFormulaSimplified()
Definition: PModule.cpp:70
bool isPreprocessor() const
Definition: PModule.h:34
bool mAppliedPreprocessing
Definition: PModule.h:21
Answer check(bool _final=false, bool _full=true, carl::Variable _objective=carl::Variable::NO_VARIABLE)
Checks the received formula for consistency.
Definition: PModule.cpp:56
Class to create the formulas for axioms.
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