SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
RewriteRules.h
Go to the documentation of this file.
1 /**
2  * @file: ApplyRules.h
3  * @author: Sebastian Junges
4  *
5  * @since March 13, 2014
6  */
7 
8 #pragma once
9 
10 #include "UsingDeclarations.h"
11 
12 namespace smtrat
13 {
14  namespace groebner
15  {
16  typedef std::map<carl::Variable, std::pair<TermT, carl::BitVector> > RewriteRules;
17 
18  template<typename Polynomial>
19  static Polynomial rewritePolynomial(const Polynomial& inputPolynomial, const RewriteRules& rules)
20  {
21  std::map<carl::Variable, TermT> substitutions;
22 
23  carl::carlVariables vars;
24  carl::BitVector resultingReasons;
25  if( Polynomial::has_reasons )
26  {
27  resultingReasons = inputPolynomial.getReasons();
28  vars = carl::variables(inputPolynomial);
29  }
30 
31  for(auto rule : rules)
32  {
33  substitutions.insert(std::make_pair(rule.first, rule.second.first));
34  if(Polynomial::has_reasons && vars.has(rule.first))
35  {
36  resultingReasons.calculateUnion(rule.second.second);
37  }
38  }
39  Polynomial result = carl::substitute(inputPolynomial, substitutions);
40  result.setReasons(resultingReasons);
41  return result;
42  }
43  }
44 }
carl::BitVector BitVector
carl::ContextPolynomial< Rational > Polynomial
Definition: common.h:16
static Polynomial rewritePolynomial(const Polynomial &inputPolynomial, const RewriteRules &rules)
Definition: RewriteRules.h:19
std::map< carl::Variable, std::pair< TermT, carl::BitVector > > RewriteRules
Definition: RewriteRules.h:16
bool substitute(const FormulaT &constr, const carl::Variable var, const carl::vs::Term< Poly > &term, FormulaT &result)
Definition: VSHelper.h:138
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Definition: QEQuery.h:43
Class to create the formulas for axioms.