SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
GBModule.h
Go to the documentation of this file.
1 /**
2  * @file GBModule.h
3  *
4  * @author Sebastian Junges
5  *
6  * The classes contained in here are
7  * GBModuleState
8  * InequalitiesTable
9  * GBModule
10  *
11  * Since: 2012-01-18
12  * Version: 2013-30-03
13  */
14 
15 #pragma once
16 
17 // Datastructures from carl
18 #include <carl-arith/groebner/groebner.h>
19 
20 // General Module interface
21 #include <smtrat-solver/Module.h>
22 
23 // Compile time settings structures
24 #include "GBSettings.h"
25 #include "RewriteRules.h"
26 
27 #include "VariableRewriteRule.h"
28 #ifdef SMTRAT_DEVOPTION_Statistics
29 #include "GBModuleStatistics.h"
31 #endif
32 
33 #include "GBModuleState.h"
34 #include "InequalitiesTable.h"
35 
36 namespace smtrat
37 {
38 /**
39  * A solver module based on Groebner basis.
40  * Details can be found in my Bachelor Thesis
41  * "On Groebner Bases in SMT-Compliant Decision Procedures"
42  * @author Sebastian Junges
43  */
44 template<class Settings>
45 class GBModule : public Module
46 {
47  friend class InequalitiesTable<Settings>;
48 public:
50  std::string moduleName() const {
51  return SettingsType::moduleName;
52  }
53  typedef typename Settings::Order Order;
54  typedef typename Settings::PolynomialWithReasons GBPolynomial;
55  typedef typename Settings::MultivariateIdeal Ideal;
56 protected:
57  /// The current Groebner basis
58  typename Settings::Groebner mBasis;
59  /// The inequalities table for handling inequalities
61  /// The vector of backtrack points, which has pointers to received constraints.
62  std::vector<ModuleInput::const_iterator> mBacktrackPoints;
63  /// Saves the relevant history to support backtracking
64  std::list<GBModuleState<Settings> > mStateHistory;
65  /// After popping in the history, it might be necessary to recalculate. This flag indicates this
67  /// A list of inequalities which were added after the last consistency check.
68  std::list<typename InequalitiesTable<Settings>::Rows::iterator> mNewInequalities;
69  /// The rewrite rules for the variables
71 
72  std::map<ConstraintT, carl::Variable> mAdditionalVarMap;
73 
74  /** A workaround to associate equalities in the passed formula originating from the gb
75  * (in contrast to those which originate from simplified formulae)
76  */
78 
79 public:
80  GBModule( const ModuleInput* const, Conditionals&, Manager* const = NULL );
81  virtual ~GBModule( );
82 
84  virtual Answer checkCore();
86 
87 
88 protected:
89  bool constraintByGB( carl::Relation cr );
90 
93  bool saveState( );
94 
97  void passGB( );
98 
99  void knownConstraintDeduction( const std::list<std::pair<carl::BitVector, carl::BitVector> >& deductions );
101  void factorisedConstraintDeduction( const std::list<GBPolynomial>& factorisation, const carl::BitVector& reasons );
102 
104 
106 
109 
113 
114 
117 
118  GBPolynomial rewriteVariable(const GBPolynomial&, const carl::Variable&, const TermT&, const BitVector&){/*TODO*/return GBPolynomial();}
119  bool validityCheck( );
120 public:
123 
124 
125 private:
126  #ifdef SMTRAT_DEVOPTION_Statistics
127  GBModuleStats& mStats = statistics_get<GBModuleStats>("GroebnerBasis");
128  GBCalculationStats& mGBStats = statistics_get<GBCalculationStats>("GB Calculation");
129  #endif //SMTRAT_DEVOPTION_Statistics
130 
131  typedef Module super;
132 };
133 } // namespace smtrat
134 #include "InequalitiesTable.tpp"
carl::BitVector BitVector
A solver module based on Groebner basis.
Definition: GBModule.h:46
std::string moduleName() const
Definition: GBModule.h:50
Settings SettingsType
Definition: GBModule.h:49
FormulaSetT generateReasonSet(const carl::BitVector &reasons)
GBPolynomial callGroebnerToSDP(const Ideal &gb)
void printRewriteRules()
void processNewConstraint(ModuleInput::const_iterator _formula)
bool mRecalculateGB
After popping in the history, it might be necessary to recalculate. This flag indicates this.
Definition: GBModule.h:66
FormulasT mGbEqualities
A workaround to associate equalities in the passed formula originating from the gb (in contrast to th...
Definition: GBModule.h:77
Settings::PolynomialWithReasons GBPolynomial
Definition: GBModule.h:54
InequalitiesTable< Settings > mInequalities
The inequalities table for handling inequalities.
Definition: GBModule.h:60
virtual Answer checkCore()
Checks the received formula for consistency.
bool constraintByGB(carl::Relation cr)
groebner::RewriteRules mRewriteRules
The rewrite rules for the variables.
Definition: GBModule.h:70
void pushBacktrackPoint(ModuleInput::const_iterator btpoint)
Settings::Order Order
Definition: GBModule.h:53
void factorisedConstraintDeduction(const std::list< GBPolynomial > &factorisation, const carl::BitVector &reasons)
std::map< ConstraintT, carl::Variable > mAdditionalVarMap
Definition: GBModule.h:72
void newConstraintDeduction()
GBPolynomial transformIntoEquality(ModuleInput::const_iterator constraint)
FormulasT generateReasons(const carl::BitVector &reasons)
bool iterativeVariableRewriting()
bool findTrivialFactorisations()
void handleConstraintToGBQueue(ModuleInput::const_iterator _formula)
void knownConstraintDeduction(const std::list< std::pair< carl::BitVector, carl::BitVector > > &deductions)
void removeReceivedFormulaFromNewInequalities(ModuleInput::const_iterator _formula)
void handleConstraintNotToGB(ModuleInput::const_iterator _formula)
Settings::MultivariateIdeal Ideal
Definition: GBModule.h:55
GBPolynomial rewriteVariable(const GBPolynomial &, const carl::Variable &, const TermT &, const BitVector &)
Definition: GBModule.h:118
void removeCore(ModuleInput::const_iterator _formula)
virtual ~GBModule()
std::vector< ModuleInput::const_iterator > mBacktrackPoints
The vector of backtrack points, which has pointers to received constraints.
Definition: GBModule.h:62
std::list< typename InequalitiesTable< Settings >::Rows::iterator > mNewInequalities
A list of inequalities which were added after the last consistency check.
Definition: GBModule.h:68
std::list< GBModuleState< Settings > > mStateHistory
Saves the relevant history to support backtracking.
Definition: GBModule.h:64
void popBacktrackPoint(ModuleInput::const_iterator btpoint)
GBModule(const ModuleInput *const, Conditionals &, Manager *const =NULL)
Settings::Groebner mBasis
The current Groebner basis.
Definition: GBModule.h:58
void printStateHistory()
bool addCore(ModuleInput::const_iterator _formula)
void removeSubformulaFromPassedFormula(ModuleInput::iterator _formula)
Datastructure for the GBModule.
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
super::iterator iterator
Passing through the list::iterator.
Definition: ModuleInput.h:144
A base class for all kind of theory solving methods.
Definition: Module.h:70
std::map< carl::Variable, std::pair< TermT, carl::BitVector > > RewriteRules
Definition: RewriteRules.h:16
Class to create the formulas for axioms.
carl::FormulaSet< Poly > FormulaSetT
Definition: types.h:41
carl::Term< Rational > TermT
Definition: types.h:23
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
carl::Formulas< Poly > FormulasT
Definition: types.h:39