6 #ifdef CLI_ENABLE_PREPROCESSOR
9 #include "../parser/InstructionHandler.h"
11 #include <carl-io/SMTLIBStream.h>
15 namespace preprocessor {
17 class PPStrategy:
public Manager {
19 PPStrategy(): Manager() {
21 addBackend<FPPModule<FPPSettings1>>()
30 carl::io::SMTLIBStream mOutput;
38 SMTRAT_LOG_WARN(
"smtrat.preprocessor",
"Preprocessor does not supprt named annotations.")
42 carl::carlVariables
vars;
43 carl::variables(solver.getInputSimplified().second,
vars);
44 mOutput.declare(
vars);
45 mOutput.assertFormula(solver.getInputSimplified().second);
46 mOutput <<
"(check-sat)" << std::endl;
48 void declareFun(
const carl::Variable&) {}
49 void declareSort(
const std::string&,
const unsigned&) {}
50 void defineSort(
const std::string&,
const std::vector<std::string>&,
const carl::Sort&) {}
53 mOutput <<
"(exit)" << std::endl;
55 void getAssertions() {}
57 mOutput <<
"(get-all-models)" << std::endl;
59 void getAssignment() {}
61 mOutput <<
"(get-model)" << std::endl;
63 void getObjectives() {}
65 void getUnsatCore() {}
66 void getValue(
const std::vector<carl::Variable>&) {}
68 void pop(std::size_t n) {
71 mOutput <<
"(pop " << n <<
")" << std::endl;
73 void push(std::size_t n) {
74 for (; n > 0; n--) this->solver.push();
75 mOutput <<
"(push " << n <<
")" << std::endl;
79 mOutput <<
"(reset)" << std::endl;
81 void resetAssertions() {
82 auto logic = solver.logic();
84 solver.rLogic() = logic;
85 mOutput <<
"(reset-assertions)" << std::endl;
87 void setLogic(
const carl::Logic& logic) {
88 solver.rLogic() = logic;
89 mOutput <<
"(set-logic " << logic <<
")" << std::endl;
91 int getExitCode()
const {
97 int preprocess_file(
const std::string& filename,
const std::string& outfile) {
98 auto e = preprocessor::Preprocessor();
101 if (outfile.empty()) {
102 e.regular() << e.mOutput;
104 std::ofstream file(outfile);
109 e.solver.printAssignment();
122 SMTRAT_LOG_ERROR(
"smtrat",
"This version of SMT-RAT was compiled without support for stand-alone preprocessing. Please enable it by setting the corresponding CMake option.");
std::optional< FormulaT > qe(const FormulaT &input)
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
carl::MultivariatePolynomial< Rational > Poly
int preprocess_file(const std::string &, const std::string &)
Loads the smt2 file specified in filename and runs the preprocessing strategy.
const auto & settings_solver()
int executeFile(const std::string &pathToInputFile, Executor &e)
Parse the file and save it in formula.
#define SMTRAT_LOG_WARN(channel, msg)
#define SMTRAT_LOG_ERROR(channel, msg)