SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
CurryModule.h
Go to the documentation of this file.
1 /**
2  * @file CurryModule.h
3  * @author Henrich Lauko <xlauko@mail.muni.cz>
4  * @author Dominika Krejci <dominika.krejci@rwth-aachen.de>
5  *
6  * @version 2018-11-18
7  * Created on 2018-11-18.
8  */
9 
10 #pragma once
11 
12 #include <smtrat-solver/Module.h>
13 #include "CurrySettings.h"
14 
15 namespace smtrat
16 {
17  template<typename Settings>
18  class CurryModule : public Module
19  {
20  private:
21  using Sort = carl::Sort;
22  using UTerm = carl::UTerm;
23  using UVariable = carl::UVariable;
24  using UFInstance = carl::UFInstance;
25  using UFunction = carl::UninterpretedFunction;
26 
27  std::unordered_map< FormulaT, FormulaT > formula_store;
28  std::unordered_map< UTerm, UTerm > term_store;
29  std::unordered_map< UFunction, UTerm > constants_store;
30 
31  std::unordered_map< FormulaT, std::vector< FormulaT > > flattened_store;
32  std::unordered_map< UTerm, UVariable > flattened_terms;
33  std::unordered_map< UVariable, std::vector< FormulaT > > flat_substitution;
34 
37 
38  auto curry(const FormulaT& formula) noexcept -> FormulaT;
39  auto curry(const UTerm& term) noexcept -> UTerm;
40 
41  auto flatten(const FormulaT& formula) noexcept -> const std::vector<FormulaT>&;
42  auto flatten(const UTerm& term, std::vector<FormulaT>& flat) noexcept -> UVariable;
43  public:
45  std::string moduleName() const {
46  return SettingsType::moduleName;
47  }
48  CurryModule(const ModuleInput* _formula, Conditionals& _conditionals, Manager* _manager = nullptr);
49 
51 
52  // Main interfaces.
53  /**
54  * Informs the module about the given constraint. It should be tried to inform this
55  * module about any constraint it could receive eventually before assertSubformula
56  * is called (preferably for the first time, but at least before adding a formula
57  * containing that constraint).
58  * @param _constraint The constraint to inform about.
59  * @return false, if it can be easily decided whether the given constraint is inconsistent;
60  * true, otherwise.
61  */
62  bool informCore( const FormulaT& _constraint );
63 
64  /**
65  * Informs all backends about the so far encountered constraints, which have not yet been communicated.
66  * This method must not and will not be called more than once and only before the first runBackends call.
67  */
68  void init();
69 
70  /**
71  * The module has to take the given sub-formula of the received formula into account.
72  *
73  * @param _subformula The sub-formula to take additionally into account.
74  * @return false, if it can be easily decided that this sub-formula causes a conflict with
75  * the already considered sub-formulas;
76  * true, otherwise.
77  */
78  bool addCore( ModuleInput::const_iterator _subformula );
79 
80  /**
81  * Removes the subformula of the received formula at the given position to the considered ones of this module.
82  * Note that this includes every stored calculation which depended on this subformula, but should keep the other
83  * stored calculation, if possible, untouched.
84  *
85  * @param _subformula The position of the subformula to remove.
86  */
88 
89  /**
90  * Updates the current assignment into the model.
91  * Note, that this is a unique but possibly symbolic assignment maybe containing newly introduced variables.
92  */
93  void updateModel() const;
94 
95  /**
96  * Checks the received formula for consistency.
97  * @return True, if the received formula is satisfiable;
98  * False, if the received formula is not satisfiable;
99  * Unknown, otherwise.
100  */
102  };
103 }
carl::UTerm UTerm
Definition: CurryModule.h:22
std::unordered_map< UVariable, std::vector< FormulaT > > flat_substitution
Definition: CurryModule.h:33
CurryModule(const ModuleInput *_formula, Conditionals &_conditionals, Manager *_manager=nullptr)
void removeCore(ModuleInput::const_iterator _subformula)
Removes the subformula of the received formula at the given position to the considered ones of this m...
auto flatten(const FormulaT &formula) noexcept -> const std::vector< FormulaT > &
auto curry(const FormulaT &formula) noexcept -> FormulaT
std::unordered_map< UFunction, UTerm > constants_store
Definition: CurryModule.h:29
bool addCore(ModuleInput::const_iterator _subformula)
The module has to take the given sub-formula of the received formula into account.
std::unordered_map< FormulaT, FormulaT > formula_store
Definition: CurryModule.h:27
std::unordered_map< UTerm, UTerm > term_store
Definition: CurryModule.h:28
auto curry(const UTerm &term) noexcept -> UTerm
carl::UFInstance UFInstance
Definition: CurryModule.h:24
bool informCore(const FormulaT &_constraint)
Informs the module about the given constraint.
auto flatten(const UTerm &term, std::vector< FormulaT > &flat) noexcept -> UVariable
std::unordered_map< FormulaT, std::vector< FormulaT > > flattened_store
Definition: CurryModule.h:31
std::unordered_map< UTerm, UVariable > flattened_terms
Definition: CurryModule.h:32
Settings SettingsType
Definition: CurryModule.h:44
Answer checkCore()
Checks the received formula for consistency.
carl::UninterpretedFunction UFunction
Definition: CurryModule.h:25
UFunction curry_function
Definition: CurryModule.h:35
void init()
Informs all backends about the so far encountered constraints, which have not yet been communicated.
void updateModel() const
Updates the current assignment into the model.
std::string moduleName() const
Definition: CurryModule.h:45
carl::UVariable UVariable
Definition: CurryModule.h:23
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