74 #ifdef SMTRAT_DEVOPTION_Statistics
75 carl::statistics::timing::time_point timer_add_started;
76 carl::statistics::timing::time_point timer_check_started;
77 carl::statistics::timing::time_point timer_remove_started;
78 carl::statistics::timing::time_point timer_pause_started;
79 carl::statistics::timing::duration timer_add_total;
80 carl::statistics::timing::duration timer_check_total;
81 carl::statistics::timing::duration timer_remove_total;
82 bool timer_add_running;
83 bool timer_check_running;
84 bool timer_remove_running;
85 std::size_t check_count = 0;
87 void collect()
override {
88 addKeyValuePair(
"timer_add_total", timer_add_total.count());
89 addKeyValuePair(
"timer_check_total", timer_check_total.count());
90 addKeyValuePair(
"timer_remove_total", timer_remove_total.count());
91 addKeyValuePair(
"check_count", check_count);
94 void start_add() { timer_add_started = carl::statistics::timing::now(); }
95 void start_check() { timer_check_started = carl::statistics::timing::now(); }
96 void start_remove() { timer_remove_started = carl::statistics::timing::now(); }
97 void pause_all() { timer_pause_started = carl::statistics::timing::now(); }
99 auto diff = carl::statistics::timing::since(timer_pause_started);
100 timer_add_started += diff;
101 timer_check_started += diff;
102 timer_remove_started += diff;
104 void stop_add() { timer_add_total += carl::statistics::timing::since(timer_add_started); }
105 void stop_check() { timer_check_total += carl::statistics::timing::since(timer_check_started); }
106 void stop_remove() { timer_remove_total += carl::statistics::timing::since(timer_remove_started); }
173 mPremise = std::move( _toMove.mPremise );
244 #ifdef SMTRAT_STRAT_PARALLEL_MODE
246 static std::mutex mOldSplittingVarMutex;
247 #define OLD_SPLITTING_VARS_LOCK_GUARD std::lock_guard<std::mutex> lock( mOldSplittingVarMutex );
248 #define OLD_SPLITTING_VARS_LOCK mOldSplittingVarMutex.lock();
249 #define OLD_SPLITTING_VARS_UNLOCK mOldSplittingVarMutex.unlock();
251 #define OLD_SPLITTING_VARS_LOCK_GUARD
252 #define OLD_SPLITTING_VARS_LOCK
253 #define OLD_SPLITTING_VARS_UNLOCK
263 Module(
const ModuleInput* _formula,
Conditionals& _foundAnswer,
Manager* _manager =
nullptr, std::string module_name =
"Module" );
328 virtual Answer check(
bool _final =
false,
bool _full =
true, carl::Variable _objective = carl::Variable::NO_VARIABLE );
396 inline std::size_t
id()
const
407 assert(
mId == 0 && _id != 0 );
523 #ifdef SMTRAT_DEVOPTION_Validation
526 mLemmas.emplace_back( _lemma, _lt, _preferredFormula );
540 if( (*module)->hasLemmas() )
556 (*module)->clearLemmas();
663 void checkInfSubsetForMinimality( std::vector<FormulaSetT>::const_iterator _infsubset,
const std::string& _filename =
"smaller_muses",
unsigned _maxSizeDifference = 1 )
const;
741 if( (*iter)->load() )
return true;
811 return _formula->origins().front();
820 return std::make_pair( _formula,
false );
829 return std::make_pair( _formula,
false );
840 module->inform( _constraint );
913 infeasibleSubset.insert( subformula->formula() );
923 infeasibleSubset.insert( _subformula->formula() );
941 std::pair<ModuleInput::iterator,bool>
addSubformulaToPassedFormula(
const FormulaT& _formula,
bool _hasSingleOrigin,
const FormulaT& _origin,
const std::shared_ptr<std::vector<FormulaT>>& _origins,
bool _mightBeConjunction );
948 std::vector<FormulaT>::const_iterator
findBestOrigin(
const std::vector<FormulaT>& _origins )
const;
959 if( posInReceived->hasOrigins() )
972 if( posInReceived->hasOrigins() )
1011 virtual Answer runBackends(
bool _final,
bool _full, carl::Variable _objective );
1048 std::vector<FormulaT>
merge(
const std::vector<FormulaT>&,
const std::vector<FormulaT>& )
const;
1067 bool probablyLooping(
const typename Poly::PolyType& _branchingPolynomial,
const Rational& _branchingValue )
const;
1086 bool branchAt(
const Poly& _polynomial,
bool _integral,
const Rational& _value, std::vector<FormulaT>&& _premise,
bool _leftCaseWeak =
true,
bool _preferLeftCase =
true,
bool _useReceivedFormulaAsPremise =
false );
1088 bool branchAt(
const Poly& _polynomial,
bool _integral,
const Rational& _value,
bool _leftCaseWeak =
true,
bool _preferLeftCase =
true,
bool _useReceivedFormulaAsPremise =
false,
const std::vector<FormulaT>& _premise = std::vector<FormulaT>() )
1090 return branchAt( _polynomial, _integral, _value, std::vector<FormulaT>( _premise ), _leftCaseWeak, _preferLeftCase, _useReceivedFormulaAsPremise );
1093 bool branchAt( carl::Variable::Arg _var,
const Rational& _value, std::vector<FormulaT>&& _premise,
bool _leftCaseWeak =
true,
bool _preferLeftCase =
true,
bool _useReceivedFormulaAsPremise =
false )
1095 return branchAt(
Poly( _var ), _var.type() == carl::VariableType::VT_INT, _value, std::move( _premise ), _leftCaseWeak, _preferLeftCase, _useReceivedFormulaAsPremise );
1098 bool branchAt( carl::Variable::Arg _var,
const Rational& _value,
bool _leftCaseWeak =
true,
bool _preferLeftCase =
true,
bool _useReceivedFormulaAsPremise =
false,
const std::vector<FormulaT>& _premise = std::vector<FormulaT>() )
1100 return branchAt(
Poly( _var ), _var.type() == carl::VariableType::VT_INT, _value, std::vector<FormulaT>( _premise ), _leftCaseWeak, _preferLeftCase, _useReceivedFormulaAsPremise );
1144 void print(
const std::string& _initiation =
"***" )
const;
1169 void printModel( std::ostream& _out = std::cout )
const;
#define OLD_SPLITTING_VARS_LOCK_GUARD
#define SMTRAT_VALIDATION_ADD(channel, name, formula, consistent)
A base class for all kind of theory solving methods.
std::pair< ModuleInput::iterator, bool > addSubformulaToPassedFormula(const FormulaT &_formula, const std::shared_ptr< std::vector< FormulaT >> &_origins)
Adds the given formula to the passed formula.
void clearModel() const
Clears the assignment, if any was found.
const std::vector< FormulaSetT > & infeasibleSubsets() const
std::pair< ModuleInput::iterator, bool > addReceivedSubformulaToPassedFormula(ModuleInput::const_iterator _subformula)
Copies the given sub-formula of the received formula to the passed formula.
ModuleInput::iterator passedFormulaEnd()
virtual void init()
Informs all backends about the so far encountered constraints, which have not yet been communicated.
std::vector< FormulaSetT > mInfeasibleSubsets
Stores the infeasible subsets.
void printReceivedFormula(const std::string &_initiation="***") const
Prints the vector of the received formula.
void splitUnequalConstraint(const FormulaT &)
Adds the following lemmas for the given constraint p!=0.
void addInformationRelevantFormula(const FormulaT &formula)
Adds a formula to the InformationRelevantFormula.
thread_priority threadPriority() const
std::vector< Model > mAllModels
Stores all satisfying assignments.
void receivedFormulasAsInfeasibleSubset(ModuleInput::const_iterator _subformula)
Stores an infeasible subset consisting only of the given received formula.
void generateTrivialInfeasibleSubset()
Stores the trivial infeasible subset being the set of received formulas.
void informBackends(const FormulaT &_constraint)
Informs all backends of this module about the given constraint.
const std::vector< Module * > & usedBackends() const
bool isPreprocessor() const
bool anAnswerFound() const
Checks for all antecedent modules and those which run in parallel with the same antecedent modules,...
std::vector< Module * > mAllBackends
The backends of this module which have been used.
virtual bool addCore([[maybe_unused]] ModuleInput::const_iterator formula)
The module has to take the given sub-formula of the received formula into account.
carl::FastSet< FormulaT > mConstraintsToInform
Stores the constraints which the backends must be informed about.
void getOrigins(const FormulaT &_formula, FormulaSetT &_origins) const
virtual std::string moduleName() const
static size_t mFirstPosInLastBranches
The beginning of the cyclic buffer storing the last branches.
ModuleInput::iterator mFirstSubformulaToPass
Stores the position of the first sub-formula in the passed formula, which has not yet been considered...
const ModuleInput * pPassedFormula() const
static void freeSplittingVariable(const FormulaT &_splittingVariable)
const std::set< FormulaT > & getInformationRelevantFormulas()
Gets all InformationRelevantFormulas.
const Model & backendsModel() const
Stores the model of a backend which determined satisfiability of the passed formula in the model of t...
Conditionals mFoundAnswer
Vector of Booleans: If any of them is true, we have to terminate a running check procedure.
virtual void updateModel() const
Updates the model, if the solver has detected the consistency of the received formula,...
virtual std::list< std::vector< carl::Variable > > getModelEqualities() const
Partition the variables from the current model into equivalence classes according to their assigned v...
std::vector< std::size_t > mVariableCounters
Maps variables to the number of their occurrences.
void deinform(const FormulaT &_constraint)
The inverse of informing about a constraint.
bool originInReceivedFormula(const FormulaT &_origin) const
unsigned currentlySatisfiedByBackend(const FormulaT &_formula) const
virtual Answer runBackends()
std::pair< ModuleInput::iterator, bool > addSubformulaToPassedFormula(const FormulaT &_formula)
Adds the given formula to the passed formula with no origin.
Answer foundAnswer(Answer _answer)
Sets the solver state to the given answer value.
bool probablyLooping(const typename Poly::PolyType &_branchingPolynomial, const Rational &_branchingValue) const
Checks whether given the current branching value and branching variable/polynomial it is (highly) pro...
ModuleInput::const_iterator firstSubformulaToPass() const
virtual ~Module()
Destructs a module.
virtual std::pair< bool, FormulaT > getReceivedFormulaSimplified()
bool mFullCheck
false, if this module should avoid too expensive procedures and rather return unknown instead.
unsigned mSmallerMusesCheckCounter
Counter used for the generation of the smt2 files to check for smaller muses.
Manager *const mpManager
A reference to the manager.
void setThreadPriority(thread_priority _threadPriority)
Sets the priority of this module to get a thread for running its check procedure.
void addOrigin(ModuleInput::iterator _formula, const FormulaT &_origin)
Adds the given set of formulas in the received formula to the origins of the given passed formula.
bool inform(const FormulaT &_constraint)
Informs the module about the given constraint.
ModuleStatistics & mStatistics
const carl::FastSet< FormulaT > & constraintsToInform() const
void printInfeasibleSubsets(const std::string &_initiation="***") const
Prints the infeasible subsets.
bool branchAt(carl::Variable::Arg _var, const Rational &_value, bool _leftCaseWeak=true, bool _preferLeftCase=true, bool _useReceivedFormulaAsPremise=false, const std::vector< FormulaT > &_premise=std::vector< FormulaT >())
const std::vector< Lemma > & lemmas() const
bool is_minimizing() const
static size_t mNumOfBranchVarsToStore
The number of different variables to consider for a probable infinite loop of branchings.
void cleanModel() const
Substitutes variable occurrences by its model value in the model values of other variables.
virtual void updateAllModels()
Updates all satisfying models, if the solver has detected the consistency of the received formula,...
void printAllModels(std::ostream &_out=std::cout)
Prints all assignments of this module satisfying its received formula if it satisfiable and this modu...
void setId(std::size_t _id)
Sets this modules unique ID to identify itself.
void clearPassedFormula()
carl::Variable objective() const
std::vector< Lemma > mLemmas
Stores the lemmas being valid formulas this module or its backends made.
const Model & model() const
void checkInfSubsetForMinimality(std::vector< FormulaSetT >::const_iterator _infsubset, const std::string &_filename="smaller_muses", unsigned _maxSizeDifference=1) const
Checks the given infeasible subset for minimality by storing all subsets of it, which have a smaller ...
void getOrigins(const FormulaT &_formula, FormulasT &_origins) const
bool isLemmaLevel(LemmaLevel level)
Checks if current lemma level is greater or equal to given level.
void updateLemmas()
Stores all lemmas of any backend of this module in its own lemma vector.
const smtrat::Conditionals & answerFound() const
Model mModel
Stores the assignment of the current satisfiable result, if existent.
std::pair< ModuleInput::iterator, bool > removeOrigins(ModuleInput::iterator _formula, const std::shared_ptr< std::vector< FormulaT >> &_origins)
thread_priority mThreadPriority
The priority of this module to get a thread for running its check procedure.
std::pair< ModuleInput::iterator, bool > addSubformulaToPassedFormula(const FormulaT &_formula, const FormulaT &_origin)
Adds the given formula to the passed formula.
virtual unsigned currentlySatisfied(const FormulaT &) const
std::vector< FormulaT >::const_iterator findBestOrigin(const std::vector< FormulaT > &_origins) const
Answer solverState() const
virtual void removeCore([[maybe_unused]] ModuleInput::const_iterator formula)
Removes everything related to the given sub-formula of the received formula.
bool hasLemmas()
Checks whether this module or any of its backends provides any lemmas.
const FormulaT & getOrigins(ModuleInput::const_iterator _formula) const
Gets the origins of the passed formula at the given position.
void excludeNotReceivedVariablesFromModel() const
Excludes all variables from the current model, which do not occur in the received formula.
virtual void addConstraintToInform(const FormulaT &_constraint)
Adds a constraint to the collection of constraints of this module, which are informed to a freshly ge...
virtual bool informCore([[maybe_unused]] const FormulaT &_constraint)
Informs the module about the given constraint.
std::atomic< Answer > mSolverState
States whether the received formula is known to be satisfiable or unsatisfiable otherwise it is set t...
void collectOrigins(const FormulaT &_formula, FormulasT &_origins) const
Collects the formulas in the given formula, which are part of the received formula.
carl::FastSet< FormulaT > mInformedConstraints
Stores the position of the first constraint of which no backend has been informed about.
bool hasValidInfeasibleSubset() const
const ModuleInput * pReceivedFormula() const
ModuleInput::iterator passedFormulaBegin()
virtual ModuleInput::iterator eraseSubformulaFromPassedFormula(ModuleInput::iterator _subformula, bool _ignoreOrigins=false)
Removes everything related to the sub-formula to remove from the passed formula in the backends of th...
virtual Answer check(bool _final=false, bool _full=true, carl::Variable _objective=carl::Variable::NO_VARIABLE)
Checks the received formula for consistency.
bool branchAt(carl::Variable::Arg _var, const Rational &_value, std::vector< FormulaT > &&_premise, bool _leftCaseWeak=true, bool _preferLeftCase=true, bool _useReceivedFormulaAsPremise=false)
unsigned checkModel() const
carl::Variable mObjectiveVariable
Objective variable to be minimized. If set to NO_VARIABLE, a normal sat check should be performed.
const ModuleInput & rReceivedFormula() const
Module(const ModuleInput *_formula, Conditionals &_foundAnswer, Manager *_manager=nullptr, std::string module_name="Module")
Constructs a module.
size_t determine_smallest_origin(const std::vector< FormulaT > &origins) const
std::vector< TheoryPropagation > mTheoryPropagations
virtual Answer checkCore()
Checks the received formula for consistency.
ModuleInput::const_iterator firstUncheckedReceivedSubformula() const
bool receivedVariable(carl::Variable::Arg _var) const
void print(const std::string &_initiation="***") const
Prints everything relevant of the solver.
void receivedFormulaChecked()
Notifies that the received formulas has been checked.
void getBackendsModel() const
void collectTheoryPropagations()
std::atomic_bool * mBackendsFoundAnswer
This flag is passed to any backend and if it determines an answer to a prior check call,...
virtual void remove(ModuleInput::const_iterator _subformula)
Removes everything related to the given sub-formula of the received formula.
std::vector< Module * > mUsedBackends
The backends of this module which are currently used (conditions to use this module are fulfilled for...
std::size_t mId
A unique ID to identify this module instance. (Could be useful but currently nowhere used)
void clearModels() const
Clears all assignments, if any was found.
bool branchAt(const Poly &_polynomial, bool _integral, const Rational &_value, std::vector< FormulaT > &&_premise, bool _leftCaseWeak=true, bool _preferLeftCase=true, bool _useReceivedFormulaAsPremise=false)
Adds a lemmas which provoke a branching for the given variable at the given value,...
bool branchAt(const Poly &_polynomial, bool _integral, const Rational &_value, bool _leftCaseWeak=true, bool _preferLeftCase=true, bool _useReceivedFormulaAsPremise=false, const std::vector< FormulaT > &_premise=std::vector< FormulaT >())
const ModuleInput & rPassedFormula() const
void printModel(std::ostream &_out=std::cout) const
Prints the assignment of this module satisfying its received formula if it satisfiable and this modul...
bool mModelComputed
True, if the model has already been computed.
const carl::FastSet< FormulaT > & informedConstraints() const
const std::vector< Model > & allModels() const
std::vector< FormulaT > merge(const std::vector< FormulaT > &, const std::vector< FormulaT > &) const
Merges the two vectors of sets into the first one.
void clearLemmas()
Deletes all yet found lemmas.
bool add(ModuleInput::const_iterator _subformula)
The module has to take the given sub-formula of the received formula into account.
const ModuleInput * mpReceivedFormula
The formula passed to this module.
static std::vector< FormulaT > mOldSplittingVariables
Reusable splitting variables.
static std::vector< Branching > mLastBranches
Stores the last branches in a cycle buffer.
void getBackendsAllModels() const
Stores all models of a backend in the list of all models of this module.
void getInfeasibleSubsets()
Copies the infeasible subsets of the passed formula.
ModuleInput * mpPassedFormula
The formula passed to the backends of this module.
virtual void deinformCore([[maybe_unused]] const FormulaT &_constraint)
The inverse of informing about a constraint.
bool mFinalCheck
true, if the check procedure should perform a final check which especially means not to postpone spli...
static bool modelsDisjoint(const Model &_modelA, const Model &_modelB)
Checks whether there is no variable assigned by both models.
void printPassedFormula(const std::string &_initiation="***") const
Prints the vector of passed formula.
ModuleInput::const_iterator mFirstUncheckedReceivedSubformula
Stores the position of the first (by this module) unchecked sub-formula of the received formula.
void addLemma(const FormulaT &_lemma, const LemmaType &_lt=LemmaType::NORMAL, const FormulaT &_preferredFormula=FormulaT(carl::FormulaType::TRUE))
Stores a lemma being a valid formula.
std::pair< ModuleInput::iterator, bool > removeOrigin(ModuleInput::iterator _formula, const FormulaT &_origin)
Class to create the formulas for axioms.
carl::FormulaSet< Poly > FormulaSetT
carl::Formula< Poly > FormulaT
carl::Model< Rational, Poly > Model
carl::MultivariatePolynomial< Rational > Poly
Answer
An enum with the possible answers a Module can give.
std::vector< std::atomic_bool * > Conditionals
A vector of atomic bool pointers.
std::ostream & operator<<(std::ostream &os, CMakeOptionPrinter cmop)
carl::Formulas< Poly > FormulasT
carl::statistics::Statistics Statistics
std::pair< std::size_t, std::size_t > thread_priority
Stores all necessary information of an branch, which can be used to detect probable infinite loop of ...
Poly::PolyType mPolynomial
The polynomial to branch at.
Branching(const typename Poly::PolyType &_polynomial, const Rational &_value)
Constructor.
Rational mValue
The value to branch the polynomial at.
size_t mRepetitions
The number of repetitions of the branching.
int mIncreasing
Stores whether this the branching of the polynomial has been on an increasing sequence of values (>0)...
FormulaT mLemma
The lemma to learn.
LemmaType mLemmaType
The type of the lemma.
FormulaT mPreferredFormula
The formula within the lemma, which should be assigned to true in the next decision.
Lemma(const FormulaT &_lemma, const LemmaType &_lemmaType, const FormulaT &_preferredFormula)
Constructor.
TheoryPropagation(const TheoryPropagation &)=delete
TheoryPropagation & operator=(const TheoryPropagation &_toMove)=delete
TheoryPropagation & operator=(TheoryPropagation &&_toMove)
FormulaT mConclusion
The propagated constraint.
FormulasT mPremise
The constraints under which the propagated constraint holds.
TheoryPropagation(TheoryPropagation &&_toMove)
TheoryPropagation()=delete
TheoryPropagation(FormulasT &&_premise, const FormulaT &_conclusion)
Constructor.