5 #include "../parser/InstructionHandler.h"
9 #include <carl-io/DIMACSExporter.h>
10 #include <carl-io/SMTLIBStream.h>
19 template<
typename Strategy>
30 settings::Settings::getInstance().get<
settings::ModuleSettings>(
"module").set_callbacks([
this](
const std::string& key){
32 }, [
this](
const std::string& key){
33 return this->
options.template get<std::string>(key);
40 this->solver.remove(f);
43 this->solver.inform(f);
50 this->solver.deinform(f);
96 error() <<
"annotated name already taken";
98 error() <<
"formula has already a name";
105 warn() <<
"no logic has been set.";
108 smtrat::resource::Limiter::getInstance().resetTimeout();
114 this->lastAnswer = std::get<0>(res);
115 m = std::get<1>(res);
116 ov = std::get<2>(res);
119 this->lastAnswer = std::get<0>(res);
120 m = std::get<1>(res);
121 ov = std::get<2>(res);
123 warn() <<
"the result might not optimal as the strategy contained a module not supporting optimization";
126 this->lastAnswer = this->solver.check();
130 switch (this->lastAnswer) {
133 if (this->
infos.template has<std::string>(
"status") && this->infos.template get<std::string>(
"status") ==
"unsat") {
134 error() <<
"expected unsat, but returned sat";
137 regular() <<
"sat" << std::endl;
144 if (this->
infos.template has<std::string>(
"status") && this->infos.template get<std::string>(
"status") ==
"sat") {
145 error() <<
"expected sat, but returned unsat";
148 regular() <<
"unsat" << std::endl;
155 regular() <<
"unknown" << std::endl;
160 regular() <<
"aborted" << std::endl;
165 error() <<
"unexpected output!";
179 void defineSort(
const std::string&,
const std::vector<std::string>&,
const carl::Sort&) {
184 #ifdef CLI_ENABLE_QUANTIFIER_ELIMINATION
185 FormulaT receivedFormula(this->solver.formula());
188 carl::io::SMTLIBStream sls;
191 if (res->type() != carl::FormulaType::FALSE) {
197 regular() <<
"unknown" << std::endl;
201 error() <<
"SMT-RAT has been built without support for quantifier elimination!";
211 regular() << assertion.formula <<
" ";
215 error() <<
"nothing is asserted";
220 for (
const auto& m: this->solver.allModels()) {
221 regular() << carl::io::asSMTLIB(m) << std::endl;
224 error() <<
"Can only be called after a call that returned sat.";
230 this->solver.printAssignment();
237 error() <<
"Can only be called after a call that returned sat.";
241 error() <<
"(get-proof) is not implemented.";
245 error() <<
"Can only be called after a call that returned sat.";
247 regular() <<
"(objectives" << std::endl;
249 const auto mv = obj.second;
250 if (mv.isMinusInfinity() || mv.isPlusInfinity()) {
251 regular() <<
" (" << obj.first <<
" " << mv.asInfinity() <<
")" << std::endl;
253 assert(mv.isRational());
254 regular() <<
" (" << obj.first <<
" " << mv.asRational() <<
")" << std::endl;
259 info() <<
"no objectives available";
268 for (
const auto& f: res.second)
regular() << f <<
" ";
271 error() <<
"got unexpected answer " << res.first;
274 error() <<
"(get-unsat-core) can only be called after (check-sat) returned unsat";
278 void getValue(
const std::vector<carl::Variable>&) {
280 error() <<
"(get-value (<variables>)) is not implemented.";
289 error() <<
"objective function already set";
294 warn() <<
"no logic has been set.";
302 warn() <<
"no logic has been set.";
309 InstructionHandler::reset();
310 smtrat::resource::Limiter::getInstance().reset();
322 error() <<
"The logic has already been set!";
constexpr int SMTRAT_EXIT_UNEXPECTED_ANSWER
constexpr int SMTRAT_EXIT_UNKNOWN
constexpr int SMTRAT_EXIT_WRONG_ANSWER
constexpr int SMTRAT_EXIT_SAT
constexpr int SMTRAT_EXIT_UNSAT
void declareFun(const carl::Variable &)
void addObjective(const smtrat::Poly &p, smtrat::parser::OptimizationType ot)
Optimization< Strategy > optimization
void addSoft(const smtrat::FormulaT &f, smtrat::Rational weight, const std::string &id)
MaxSMT< Strategy, MaxSMTStrategy::LINEAR_SEARCH > maxsmt
Executor(Strategy &solver)
void declareSort(const std::string &, const unsigned &)
execution::ExecutionState state
void defineSort(const std::string &, const std::vector< std::string > &, const carl::Sort &)
void annotateName(const smtrat::FormulaT &f, const std::string &name)
void getValue(const std::vector< carl::Variable > &)
smtrat::Answer lastAnswer
UnsatCore< Strategy, UnsatCoreStrategy::ModelExclusion > unsatcore
void add(const smtrat::FormulaT &f)
void setLogic(const carl::Logic &logic)
void add_soft_formula(const FormulaT &formula, Rational weight, const std::string &id)
void remove_soft_formula(const FormulaT &formula)
std::tuple< Answer, Model, ObjectiveValues > compute()
void add_objective(const Poly &objective, bool minimize=true)
void remove_objective(const Poly &objective)
std::tuple< Answer, Model, ObjectiveValues > compute(bool full=true)
std::pair< Answer, std::vector< std::string > > compute()
void add_annotated_name(const FormulaT &formula, const std::string &name)
void remove_annotated_name(const FormulaT &formula)
void add_assertion(const FormulaT &formula)
void set_add_soft_assertion_handler(std::function< void(const FormulaT &, Rational, const std::string &)> f)
bool has_objective(const Poly &function)
const auto & assertions() const
void set_remove_objective_handler(std::function< void(const Poly &)> f)
void set_add_assertion_handler(std::function< void(const FormulaT &)> f)
void set_remove_annotated_name_handler(std::function< void(const FormulaT &)> f)
bool has_soft_assertion(const FormulaT &formula) const
bool has_assertion(const FormulaT &formula) const
bool has_annotated_name_formula(const smtrat::FormulaT &f)
const smtrat::Model & model() const
void set_add_objective_handler(std::function< void(const Poly &, bool)> f)
bool has_annotated_name(const std::string &n)
void add_soft_assertion(const FormulaT &formula, Rational weight, const std::string &id)
void annotate_name(const std::string &name, const smtrat::FormulaT &f)
bool is_mode(Mode mode) const
void set_logic(carl::Logic logic)
void enter_sat(const smtrat::Model &model, const ObjectiveValues &objectiveValues)
void set_add_annotated_name_handler(std::function< void(const FormulaT &, const std::string &)> f)
void add_objective(const Poly &function, bool minimize)
const smtrat::ObjectiveValues & objectiveValues() const
void set_remove_soft_assertion_handler(std::function< void(const FormulaT &)> f)
void set_remove_assertion_handler(std::function< void(const FormulaT &)> f)
VariantMap< std::string, Value > options
VariantMap< std::string, Value > infos
std::optional< FormulaT > qe(const FormulaT &formula)
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
std::vector< std::pair< std::variant< Poly, std::string >, Model::mapped_type > > ObjectiveValues
carl::Model< Rational, Poly > Model
carl::MultivariatePolynomial< Rational > Poly
Answer
An enum with the possible answers a Module can give.
#define SMTRAT_LOG_DEBUG(channel, msg)