13 template<
typename Rational,
typename Poly>
15 CARL_LOG_DEBUG(
"carl.model.evaluation",
"Evaluating " << f <<
" on " << m);
18 CARL_LOG_DEBUG(
"carl.model.evaluation",
"Evaluating " << r <<
" on " << m);
26 template<
typename Rational,
typename Poly>
28 CARL_LOG_DEBUG(
"carl.model.evaluation",
"Evaluating " << f <<
" on " << m);
37 CARL_LOG_DEBUG(
"carl.model.evaluation",
"MVRoot does not exist, returning false");
45 CARL_LOG_DEBUG(
"carl.model.evaluation",
"Evaluated substitution to " << cmp);
48 CARL_LOG_DEBUG(
"carl.model.evaluation",
"MVRoot is still a substitution, cannot evaluate.");
55 auto it = m.
find(vc.var());
57 CARL_LOG_DEBUG(
"carl.model.evaluation",
"Could not evaluate " << vc <<
" as " << vc.var() <<
" is not part of the model");
60 const auto& value = m.
evaluated(vc.var());
61 assert(value.isRational() || value.isRAN());
62 typename Poly::RootType reference = value.isRational() ?
typename Poly::RootType(value.asRational()) : value.asRAN();
63 CARL_LOG_DEBUG(
"carl.model.evaluation",
"Reference value: " << vc.var() <<
" == " << reference);
66 CARL_LOG_DEBUG(
"carl.model.evaluation",
"Comparison: " << reference <<
" " << vc.relation() <<
" " << val);
67 switch (vc.relation()) {
89 CARL_LOG_DEBUG(
"carl.model.evaluation",
"Applying negation, result is " << f);
93 template<
typename Rational,
typename Poly>
97 auto it = m.
find(va.var());
98 if (it == m.
end())
return;
99 const auto& value = m.
evaluated(va.var());
101 if (value == vavalue) {
106 if (va.negated()) f = f.
negated();
114 template<
typename Rational,
typename Poly>
122 CARL_LOG_WARN(
"carl.model.evaluation",
"Evaluation of exists not yet implemented.");
125 CARL_LOG_WARN(
"carl.model.evaluation",
"Evaluation of forall not yet implemented.");
131 if (it == m.
end())
break;
132 if (it->second.isBool()) {
135 CARL_LOG_WARN(
"carl.model.evaluation",
"Could not evaluate " << it->first <<
" as a boolean, value is " << it->second);
157 assert(res.isSubstitution());
158 const auto& subs = res.asSubstitution();
160 f = fsubs->getFormula();
180 std::set<UVariable> vars;
184 assert(val.isBool());
187 CARL_LOG_WARN(
"carl.model.evaluation",
"Could not evaluate " << f.
u_equality() <<
" as some variables are missing from the model.");
198 template<
typename Rational,
typename Poly>
203 else res = createSubstitution<Rational,Poly,ModelFormulaSubstitution<Rational,Poly>>(f);
A small wrapper that configures logging for carl.
#define CARL_LOG_WARN(channel, msg)
#define CARL_LOG_DEBUG(channel, msg)
carl is the main namespace for the library.
std::vector< Formula< Poly > > Formulas
bool evaluate(const BasicConstraint< Poly > &c, const Assignment< Number > &m)
Coeff substitute(const Monomial &m, const std::map< Variable, Coeff > &substitutions)
Applies the given substitutions to a monomial.
void evaluate_inplace(ModelValue< Rational, Poly > &res, BVTerm &bvt, const Model< Rational, Poly > &m)
Evaluates a bitvector term to a ModelValue over a Model.
void substitute_inplace(MultivariateRoot< Poly > &mr, Variable var, const Poly &poly)
Create a copy of the underlying polynomial with the given variable replaced by the given polynomial.
void evaluateVarCompare(Formula< Poly > &f, const Model< Rational, Poly > &m)
void substituteSubformulas(Formula< Poly > &f, const Model< Rational, Poly > &m)
void evaluateVarAssign(Formula< Poly > &f, const Model< Rational, Poly > &m)
bool isAlwaysInconsistent() const
bool isAlwaysConsistent() const
const VariableAssignment< Pol > & variable_assignment() const
const Formula & subformula() const
const VariableComparison< Pol > & variable_comparison() const
const Formula & premise() const
const Formula & conclusion() const
carl::Variable::Arg boolean() const
const Constraint< Pol > & constraint() const
const Formulas< Pol > & subformulas() const
const Formula & first_case() const
const Formula & second_case() const
const BVConstraint & bv_constraint() const
const UEquality & u_equality() const
const Formula & condition() const
Represent a collection of assignments/mappings from variables to values.
auto find(const typename Map::key_type &key) const
const ModelValue< Rational, Poly > & evaluated(const typename Map::key_type &key) const
Return the ModelValue for the given key, evaluated if it's a ModelSubstitution and evaluatable,...
bool contains(const Container &c) const
Represent a sum type/variant over the different kinds of values that can be assigned to the different...
const Poly::RootType & asRAN() const
const ModelSubstitutionPtr< Rational, Poly > & asSubstitution() const
const Rational & asRational() const
bool isSubstitution() const
void gatherUVariables(std::set< UVariable > &uvars) const