SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
PFEModule.h
Go to the documentation of this file.
1 /**
2  * Removes factors of polynomials from the formula.
3  *
4  * @file PFEModule.h
5  * @author Gereon Kremer <gereon.kremer@cs.rwth-aachen.de>
6  * @author Florian Corzilius <corzilius@cs.rwth-aachen.de>
7  *
8  * @version 2015-09-10
9  * Created on 2015-09-10.
10  */
11 
12 #pragma once
13 
14 #include <smtrat-solver/PModule.h>
16 #include "PFESettings.h"
17 
18 namespace smtrat
19 {
20  template<typename Settings>
21  class PFEModule : public PModule
22  {
23  private:
24  // Members.
25  ///
26  /// Collection of bounds of all received formulas.
28  bool boundsChanged = false;
29  public:
31  PFEModule( const ModuleInput* _formula, Conditionals& _conditionals, Manager* _manager = NULL );
32 
34 
35  // Main interfaces.
37 
38  /**
39  * Checks the received formula for consistency.
40  * @return SAT, if the received formula is satisfiable;
41  * UNSAT, if the received formula is not satisfiable;
42  * Unknown, otherwise.
43  */
46  private:
47 
48  carl::Relation combine(carl::Relation lhs, carl::Relation rhs, std::size_t exponent) {
49  assert(lhs != carl::Relation::NEQ);
50  assert(rhs != carl::Relation::NEQ);
51  if (rhs == carl::Relation::EQ) return carl::Relation::EQ;
52  if (exponent % 2 == 0) {
53  if (rhs == carl::Relation::LEQ) rhs = carl::Relation::GEQ;
54  else if (rhs == carl::Relation::LESS) rhs = carl::Relation::GREATER;
55  }
56  switch (lhs) {
57  case carl::Relation::GREATER: return rhs;
58  case carl::Relation::GEQ:
59  switch (rhs) {
60  case carl::Relation::GREATER:
61  case carl::Relation::GEQ: return carl::Relation::GEQ;
62  case carl::Relation::LEQ:
63  case carl::Relation::LESS: return carl::Relation::LEQ;
64  default: return carl::Relation::NEQ;
65  }
67  case carl::Relation::LEQ:
68  switch (rhs) {
69  case carl::Relation::GREATER:
70  case carl::Relation::GEQ: return carl::Relation::LEQ;
71  case carl::Relation::LEQ:
72  case carl::Relation::LESS: return carl::Relation::GEQ;
73  default: return carl::Relation::NEQ;
74  }
75  case carl::Relation::LESS:
76  switch (rhs) {
77  case carl::Relation::GREATER: return carl::Relation::LESS;
78  case carl::Relation::GEQ: return carl::Relation::LEQ;
79  case carl::Relation::LEQ: return carl::Relation::GEQ;
80  case carl::Relation::LESS: return carl::Relation::GREATER;
81  default: return carl::Relation::NEQ;
82  }
83  case carl::Relation::NEQ: return carl::Relation::NEQ;
84  }
85  return carl::Relation::NEQ;
86  }
87 
88  Poly getPoly(const std::vector<Factorization::const_iterator>& its) const {
89  Poly res(1);
90  for (const auto& it: its) res *= carl::pow(it->first, it->second);
91  return res;
92  }
93 
95  for (const auto& bound: varbounds.getEvalIntervalMap()) {
96  if (bound.second.is_point_interval()) {
97  FormulasT origins = varbounds.getOriginsOfBounds(bound.first);
98  addSubformulaToPassedFormula(FormulaT(bound.first - bound.second.lower(), carl::Relation::EQ), std::make_shared<std::vector<FormulaT>>(std::move(origins)));
99  }
100  }
101  }
102 
104  auto res = varbounds.getEvalIntervalMap();
105  for (auto var: carl::variables(p)) {
106  if (res.find(var) == res.end()) {
107  res[var] = RationalInterval::unbounded_interval();
108  }
109  }
110  return res;
111  }
112 
113  /**
114  * Removes redundant or obsolete factors of polynomials from the formula.
115  */
116  FormulaT removeFactors(const FormulaT& formula);
118 
120  FormulaT removeSquares(const FormulaT& formula);
122 
126  };
127 }
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
std::pair< ModuleInput::iterator, bool > addSubformulaToPassedFormula(const FormulaT &_formula)
Adds the given formula to the passed formula with no origin.
Definition: Module.h:873
PFEModule(const ModuleInput *_formula, Conditionals &_conditionals, Manager *_manager=NULL)
FormulaT implyDefinitenessFromStrict(const FormulaT &formula)
std::function< FormulaT(FormulaT)> implyDefinitenessFunction
Definition: PFEModule.h:125
std::function< FormulaT(FormulaT)> removeFactorsFunction
Definition: PFEModule.h:117
Settings SettingsType
Definition: PFEModule.h:30
FormulaT implyDefiniteness(const FormulaT &formula)
void generateVariableAssignments()
Definition: PFEModule.h:94
FormulaT removeSquares(const FormulaT &formula)
vb::VariableBounds< FormulaT > varbounds
Collection of bounds of all received formulas.
Definition: PFEModule.h:27
Answer checkCore()
Checks the received formula for consistency.
EvalRationalIntervalMap completeBounds(const Poly &p) const
Definition: PFEModule.h:103
std::function< FormulaT(FormulaT)> removeSquaresFunction
Definition: PFEModule.h:121
Poly getPoly(const std::vector< Factorization::const_iterator > &its) const
Definition: PFEModule.h:88
void removeCore(ModuleInput::const_iterator)
bool addCore(ModuleInput::const_iterator)
FormulaT removeFactors(const FormulaT &formula)
Removes redundant or obsolete factors of polynomials from the formula.
carl::Relation combine(carl::Relation lhs, carl::Relation rhs, std::size_t exponent)
Definition: PFEModule.h:48
FormulaT removeSquaresFromStrict(const FormulaT &formula)
const EvalRationalIntervalMap & getEvalIntervalMap() const
Creates an evalintervalmap corresponding to the variable bounds.
std::vector< T > getOriginsOfBounds(const carl::Variable &_var) const
int var(Lit p)
Definition: SolverTypes.h:64
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
Definition: types.h:37
const settings::Settings & Settings()
Definition: Settings.h:96
std::map< carl::Variable, RationalInterval > EvalRationalIntervalMap
Definition: model.h:30
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
carl::Formulas< Poly > FormulasT
Definition: types.h:39