SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
PModule.cpp
Go to the documentation of this file.
1 /**
2  * @file PModule.cpp
3  * @author Florian Corzilius <corzilius@cs.rwth-aachen.de>
4  *
5  * @version 2015-09-09
6  * Created on 2015-09-09.
7  */
8 
9 #include "PModule.h"
10 
11 namespace smtrat
12 {
13  PModule::PModule( const ModuleInput* _formula, Conditionals& _foundAnswer, Manager* _manager, std::string module_name ):
14  Module( _formula, _foundAnswer, _manager, std::move(module_name) )
15  {
16  }
17 
19  if( solverState() == UNSAT ) {
20  SMTRAT_LOG_WARN("smtrat.pmodule", moduleName() << ": Returning FALSE");
21  mSimplifiedFormula = std::make_pair( true, FormulaT( carl::FormulaType::FALSE ) );
22  return;
23  }
24  for( auto& backend : usedBackends() )
25  {
26  std::pair<bool,FormulaT> simplifiedPassedFormula = backend->getReceivedFormulaSimplified();
27  if( simplifiedPassedFormula.first )
28  {
29  SMTRAT_LOG_WARN("smtrat.pmodule", moduleName() << ": Returning from backend: " << simplifiedPassedFormula.second);
30  mSimplifiedFormula = simplifiedPassedFormula;
31  return;
32  }
33  }
35  {
36  SMTRAT_LOG_WARN("smtrat.pmodule", moduleName() << ": Returning " << FormulaT(rPassedFormula()));
37  mSimplifiedFormula = std::make_pair( true, (FormulaT) rPassedFormula() );
38  return;
39  }
40  SMTRAT_LOG_WARN("smtrat.pmodule", moduleName() << ": No simplifications");
41  mSimplifiedFormula = std::make_pair( false, FormulaT( carl::FormulaType::TRUE ) );
42  }
43 
45  {
46  mAppliedPreprocessing = false;
47  return Module::add( _subformula );
48  }
49 
51  {
52  mAppliedPreprocessing = false;
53  return Module::remove( _subformula );
54  }
55 
56  Answer PModule::check( bool _final, bool _full, carl::Variable _objective )
57  {
58  Answer res = Module::check(_final, _full, _objective);
60  SMTRAT_LOG_WARN("smtrat.pmodule", moduleName() << ": Simplified = " << mSimplifiedFormula);
61  return res;
62  }
63 
64  Answer PModule::runBackends( bool _final, bool _full, carl::Variable _objective )
65  {
66  mAppliedPreprocessing = true;
67  return Module::runBackends( _final, _full, _objective );
68  }
69 
70  std::pair<bool,FormulaT> PModule::getReceivedFormulaSimplified()
71  {
72  return mSimplifiedFormula;
73  }
74 
75  void PModule::updateModel() const {
76  clearModel();
77  if (solverState() == SAT || (solverState() != UNSAT && appliedPreprocessing())) {
79  SMTRAT_LOG_DEBUG("smtrat.pmodule", moduleName() << ": obtained backend model" << std::endl << mModel);
80  }
81  }
82 }
All preprocessing modules shall derive from this module, that is modules, which simplify their receiv...
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
void clearModel() const
Clears the assignment, if any was found.
Definition: Module.h:749
const std::vector< Module * > & usedBackends() const
Definition: Module.h:488
virtual std::string moduleName() const
Definition: Module.h:615
virtual Answer runBackends()
Definition: Module.h:1012
Model mModel
Stores the assignment of the current satisfiable result, if existent.
Definition: Module.h:199
Answer solverState() const
Definition: Module.h:388
virtual Answer check(bool _final=false, bool _full=true, carl::Variable _objective=carl::Variable::NO_VARIABLE)
Checks the received formula for consistency.
Definition: Module.cpp:86
void getBackendsModel() const
Definition: Module.cpp:652
virtual void remove(ModuleInput::const_iterator _subformula)
Removes everything related to the given sub-formula of the received formula.
Definition: Module.cpp:159
const ModuleInput & rPassedFormula() const
Definition: Module.h:455
bool add(ModuleInput::const_iterator _subformula)
The module has to take the given sub-formula of the received formula into account.
Definition: Module.cpp:138
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 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.
carl::Formula< Poly > FormulaT
Definition: types.h:37
Answer
An enum with the possible answers a Module can give.
Definition: types.h:57
@ SAT
Definition: types.h:57
@ UNSAT
Definition: types.h:57
std::vector< std::atomic_bool * > Conditionals
A vector of atomic bool pointers.
Definition: types.h:17
#define SMTRAT_LOG_WARN(channel, msg)
Definition: logging.h:33
#define SMTRAT_LOG_DEBUG(channel, msg)
Definition: logging.h:35