carl  24.04
Computer ARithmetic Library
ModelConditionalSubstitution.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "../ModelSubstitution.h"
4 #include "../evaluation/ModelEvaluation.h"
5 
6 namespace carl {
7  template<typename Rational, typename Poly>
8  class ModelConditionalSubstitution: public ModelSubstitution<Rational,Poly> {
9  private:
11  std::vector<std::pair<Formula<Poly>, ModelValue<Rational,Poly>>> mValues;
12  public:
14  {}
15  ModelConditionalSubstitution(std::initializer_list<std::pair<Formula<Poly>, ModelValue<Rational,Poly>>> values): ModelSubstitution<Rational,Poly>(), mValues(values)
16  {}
17  virtual void multiplyBy(const Rational& n) {
18  assert(false);
19  }
20  virtual void add(const Rational& n) {
21  assert(false);
22  }
24  return createSubstitutionPtr<Rational,Poly,ModelConditionalSubstitution>(mValues);
25  }
26 
28  assert(mv.is_variable());
29  Formulas<Poly> subs;
30  for (const auto& v: mValues) {
31  //subs.emplace_back(Formula<Poly>())
32  }
33  return Formula<Poly>(FormulaType::AND, std::move(subs));
34  }
36  //return evaluate(mPoly, model);
37  return true;
38  }
39  virtual bool dependsOn(const ModelVariable& var) const {
40  if (!var.is_variable()) return false;
41  for (const auto& v: mValues) {
42 
43  }
44  return false;
45  }
46  virtual void print(std::ostream& os) const {
47  os << "(";
48  for (const auto& v: mValues) {
49  os << "if " << v.first << ": " << v.second << "; ";
50  }
51  }
52  };
53 }
mpq_class Rational
Definition: HornerTest.cpp:12
carl is the main namespace for the library.
std::vector< Formula< Poly > > Formulas
std::unique_ptr< ModelSubstitution< Rational, Poly > > ModelSubstitutionPtr
Definition: ModelValue.h:24
Represent a collection of assignments/mappings from variables to values.
Definition: Model.h:19
Represent a expression for a ModelValue with variables as placeholders, where the final expression's ...
Represent a sum type/variant over the different kinds of values that can be assigned to the different...
Definition: ModelValue.h:56
Represent a sum type/variant over the different kinds of variables that exist in CARL to use them in ...
Definition: ModelVariable.h:20
bool is_variable() const
Definition: ModelVariable.h:44
ModelConditionalSubstitution(const std::vector< std::pair< Formula< Poly >, ModelValue< Rational, Poly >>> &values)
virtual void print(std::ostream &os) const
Print this substitution to the given output stream.
virtual bool dependsOn(const ModelVariable &var) const
Check if this substitution needs the given model variable.
virtual ModelSubstitutionPtr< Rational, Poly > clone() const
Create a copy of this model substitution.
virtual void add(const Rational &n)
Add a rational to this model substitution.
ModelConditionalSubstitution(std::initializer_list< std::pair< Formula< Poly >, ModelValue< Rational, Poly >>> values)
virtual ModelValue< Rational, Poly > evaluateSubstitution(const Model< Rational, Poly > &model) const
Evaluate this substitution with respect to the given model.
virtual Formula< Poly > representingFormula(const ModelVariable &mv)
std::vector< std::pair< Formula< Poly >, ModelValue< Rational, Poly > > > mValues
virtual void multiplyBy(const Rational &n)
Multiply this model substitution by a rational.