SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
STropModule.h
Go to the documentation of this file.
1 /**
2  * @file STropModule.h
3  * @author Ă–mer Sali <oemer.sali@rwth-aachen.de>
4  *
5  * @version 2018-04-04
6  * Created on 2017-09-13.
7  */
8 
9 #pragma once
10 
11 #include "../LRAModule/LRAModule.h"
12 #include "../SATModule/SATModule.h"
13 #include "STropModuleStatistics.h"
14 #include "STropSettings.h"
15 #include "Subtropical.h"
16 #include <optional>
17 #include <smtrat-solver/Manager.h>
18 #include <smtrat-solver/Module.h>
19 
20 namespace smtrat {
21 template<typename Settings>
22 class STropModule : public Module {
23 private:
24  SMTRAT_STATISTICS_INIT(STropModuleStatistics, mStatistics, Settings::moduleName);
25 
26  /// Holds encoding information.
28 
29  /**
30  * Represents the class of all original constraints with the same
31  * left hand side after a normalization. Here, the set of all received
32  * relations of constraints with the same left hand side is stored. At any
33  * one time only one relation can be active and used for linearization.
34  */
35  struct SeparatorGroup {
36  /// The hyperplane encoding.
38  /// Relations of constraints with the same left hand side
39  std::set<carl::Relation> mRelations;
40  /// Direction currently used for linearization
41  std::optional<subtropical::Direction> mActiveDirection;
42  /// Check if relations induce an equational constraint
44  /// Active formula.
46 
47  SeparatorGroup(const Poly& normalization)
48  : mSeparator(normalization), mRelations(), mActiveDirection(std::nullopt), mEquationInduced(false), mActiveFormula(carl::FormulaType::FALSE) {}
49  };
50 
51  /// Maps a normalized left hand side of a constraint to its separator
52  std::unordered_map<Poly, SeparatorGroup> mSeparators;
53  /// Stores the Separators that were updated since the last check call
54  std::unordered_set<SeparatorGroup*> mChangedSeparators;
55  /// Counts the number of relation pairs that prohibit an application of this method
57  /// Stores the sets of separators that were found to be undecidable by the LRA solver
58  typedef std::vector<std::pair<const SeparatorGroup*, const subtropical::Direction>> Conflict;
59  std::vector<Conflict> mLinearizationConflicts;
60  /// Stores whether the last consistency check was done by the backends
62  /// Stores the formulas for integer variables
63  std::unordered_map<carl::Variable, FormulaT> mActiveIntegerFormulas;
64 
65  /**
66  * Linear arithmetic module to call for the linearized formula.
67  */
68  struct LAModule : public Manager {
70  : Manager() {
71  setStrategy({addBackend<SATModule<SATSettings1>>({addBackend<LRAModule<LRASettings1>>()})});
72  }
73  };
74 
75  /// Handle to the linear arithmetic module
77 
78 public:
80 
81  std::string moduleName() const {
82  return SettingsType::moduleName;
83  }
84 
85  STropModule(const ModuleInput* _formula, Conditionals& _conditionals, Manager* _manager = nullptr);
86 
87  /**
88  * The module has to take the given sub-formula of the received formula into account.
89  * @param _subformula The sub-formula to take additionally into account.
90  * @return False, if it can be easily decided that this sub-formula causes a conflict with
91  * the already considered sub-formulas;
92  * True, otherwise.
93  */
95 
96  /**
97  * Removes the subformula of the received formula at the given position to the considered ones of this module.
98  * Note that this includes every stored calculation which depended on this subformula, but should keep the other
99  * stored calculation, if possible, untouched.
100  * @param _subformula The position of the subformula to remove.
101  */
103 
104  /**
105  * Updates the current assignment into the model.
106  * Note, that this is a unique but possibly symbolic assignment maybe containing newly introduced variables.
107  */
108  void updateModel() const;
109 
110  /**
111  * Checks the received formula for consistency.
112  * @return SAT, if the received formula is satisfiable;
113  * UNSAT, if the received formula is not satisfiable;
114  * UNKNOWN, otherwise.
115  */
117 
118 private:
119  /**
120  * Adds the given formula to the LRA solver.
121  * @param formula The formula to add to the LRA solver.
122  */
123  inline void add_lra_formula(const FormulaT& formula);
124 
125  /**
126  * Removes the given formula from the LRA solver.
127  * @param formula The formula to remove to the LRA solver.
128  */
129  inline void remove_lra_formula(const FormulaT& formula);
130 };
131 } // namespace smtrat
Base class for solvers.
Definition: Manager.h:34
void setStrategy(const std::initializer_list< BackendLink > &backends)
Definition: Manager.h:385
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
void updateModel() const
Updates the current assignment into the model.
bool addCore(ModuleInput::const_iterator _subformula)
The module has to take the given sub-formula of the received formula into account.
void remove_lra_formula(const FormulaT &formula)
Removes the given formula from the LRA solver.
std::vector< std::pair< const SeparatorGroup *, const subtropical::Direction > > Conflict
Stores the sets of separators that were found to be undecidable by the LRA solver.
Definition: STropModule.h:58
STropModule(const ModuleInput *_formula, Conditionals &_conditionals, Manager *_manager=nullptr)
size_t mRelationalConflicts
Counts the number of relation pairs that prohibit an application of this method.
Definition: STropModule.h:56
std::vector< Conflict > mLinearizationConflicts
Definition: STropModule.h:59
SMTRAT_STATISTICS_INIT(STropModuleStatistics, mStatistics, Settings::moduleName)
std::string moduleName() const
Definition: STropModule.h:81
std::unordered_set< SeparatorGroup * > mChangedSeparators
Stores the Separators that were updated since the last check call.
Definition: STropModule.h:54
std::unordered_map< Poly, SeparatorGroup > mSeparators
Maps a normalized left hand side of a constraint to its separator.
Definition: STropModule.h:52
Answer checkCore()
Checks the received formula for consistency.
Settings SettingsType
Definition: STropModule.h:79
void add_lra_formula(const FormulaT &formula)
Adds the given formula to the LRA solver.
subtropical::Encoding mEncoding
Holds encoding information.
Definition: STropModule.h:27
LAModule mLRAModule
Handle to the linear arithmetic module.
Definition: STropModule.h:76
bool mCheckedWithBackends
Stores whether the last consistency check was done by the backends.
Definition: STropModule.h:61
std::unordered_map< carl::Variable, FormulaT > mActiveIntegerFormulas
Stores the formulas for integer variables.
Definition: STropModule.h:63
void removeCore(ModuleInput::const_iterator _subformula)
Removes the subformula of the received formula at the given position to the considered ones of this m...
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
Definition: types.h:37
const settings::Settings & Settings()
Definition: Settings.h:96
carl::MultivariatePolynomial< Rational > Poly
Definition: types.h:25
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
Linear arithmetic module to call for the linearized formula.
Definition: STropModule.h:68
Represents the class of all original constraints with the same left hand side after a normalization.
Definition: STropModule.h:35
subtropical::Separator mSeparator
The hyperplane encoding.
Definition: STropModule.h:37
bool mEquationInduced
Check if relations induce an equational constraint.
Definition: STropModule.h:43
FormulaT mActiveFormula
Active formula.
Definition: STropModule.h:45
std::optional< subtropical::Direction > mActiveDirection
Direction currently used for linearization.
Definition: STropModule.h:41
SeparatorGroup(const Poly &normalization)
Definition: STropModule.h:47
std::set< carl::Relation > mRelations
Relations of constraints with the same left hand side.
Definition: STropModule.h:39
Represents the class of all original constraints with the same left hand side after a normalization.
Definition: Subtropical.h:86