Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SmtlibSmtSolver.h
Go to the documentation of this file.
1#ifndef STORM_SOLVER_SMT2SMTSOLVER
2#define STORM_SOLVER_SMT2SMTSOLVER
3
4#include <fstream>
5#include <iostream>
6
7#include "storm-config.h"
11
12namespace storm {
13namespace solver {
20class SmtlibSmtSolver : public SmtSolver {
21 public:
23 public:
25 virtual bool getBooleanValue(storm::expressions::Variable const& variable) const override;
26 virtual int_fast64_t getIntegerValue(storm::expressions::Variable const& variable) const override;
27 virtual double getRationalValue(storm::expressions::Variable const& variable) const override;
28 virtual std::string toString() const override;
29 };
30
31 public:
37 SmtlibSmtSolver(storm::expressions::ExpressionManager& manager, bool useCarlExpressions = false);
38 virtual ~SmtlibSmtSolver();
39
40 virtual void push() override;
41
42 virtual void pop() override;
43
44 virtual void pop(uint_fast64_t n) override;
45
46 virtual void reset() override;
47
48 virtual void add(storm::expressions::Expression const& assertion) override;
49#ifdef STORM_HAVE_CARL
50 // adds the constraint "leftHandSide relation rightHandSide"
51 virtual void add(storm::RationalFunction const& leftHandSide, storm::CompareRelation const& relation,
52 storm::RationalFunction const& rightHandSide = storm::RationalFunction(0));
53
54 // asserts that the given variable has the given value. The variable should have type 'bool'
55 void add(storm::RationalFunctionVariable const& variable, bool value);
56#endif
57
58 virtual CheckResult check() override;
59
60 virtual CheckResult checkWithAssumptions(std::set<storm::expressions::Expression> const& assumptions) override;
61
62 virtual CheckResult checkWithAssumptions(std::initializer_list<storm::expressions::Expression> const& assumptions) override;
63
64 bool isNeedsRestart() const;
65
66 // Todo: some of these might be added in the future
67 // virtual storm::expressions::SimpleValuation getModelAsValuation() override;
68
69 // virtual std::shared_ptr<SmtSolver::ModelReference> getModel() override;
70
71 // virtual std::vector<storm::expressions::SimpleValuation> allSat(std::vector<storm::expressions::Variable> const& important) override;
72
73 // virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important, std::function<bool(storm::expressions::SimpleValuation&)>
74 // const& callback) override;
75
76 // virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important, std::function<bool(ModelReference&)> const& callback) override;
77
78 // virtual std::vector<storm::expressions::Expression> getUnsatAssumptions() override;
79
80 private:
85 void init();
86
92 void writeCommand(std::string smt2Command, bool expectSuccess);
93
99 std::vector<std::string> readSolverOutput(bool waitForOutput = true);
100
110 void checkForErrorMessage(const std::string message);
111
112#ifndef WINDOWS
113 // descriptors for the pipe from and to the solver
114 int toSolver;
115 int fromSolver;
116 // A flag storing the Process ID of the solver. If this is zero, then the solver is not running
117 pid_t processIdOfSolver;
118#endif
119
120 // a filestream where the commands that we send to the solver will be stored (can be used for debugging purposes)
121 std::ofstream commandFile;
122
123 bool isCommandFileOpen;
124
125 // An expression adapter that is used for translating the expression into Smt2's format.
126 std::unique_ptr<storm::adapters::Smt2ExpressionAdapter> expressionAdapter;
127
128 // A flag storing whether the last call to a check method provided aussumptions.
129 // bool lastCheckAssumptions;
130
131 // The last result that was returned by any of the check methods.
132 // CheckResult lastResult;
133
134 // A flag that states whether we want to use carl expressions.
135 bool useCarlExpressions;
136
137 // A flag that states whether to use readable variable names
138 bool useReadableVarNames = true;
139
140 // A flag that states whether some error has occured
141 bool needsRestart = false;
142};
143} // namespace solver
144} // namespace storm
145#endif // STORM_SOLVER_SMT2SMTSOLVER
This class is responsible for managing a set of typed variables and all expressions using these varia...
The base class for all model references.
Definition SmtSolver.h:31
An interface that captures the functionality of an SMT solver.
Definition SmtSolver.h:22
CheckResult
possible check results
Definition SmtSolver.h:25
virtual bool getBooleanValue(storm::expressions::Variable const &variable) const override
virtual std::string toString() const override
virtual int_fast64_t getIntegerValue(storm::expressions::Variable const &variable) const override
virtual double getRationalValue(storm::expressions::Variable const &variable) const override
This class represents an SMT-LIBv2 conforming solver.
virtual CheckResult check() override
Checks whether the conjunction of assertions that are currently on the solver's stack is satisfiable.
virtual void push() override
Pushes a backtracking point on the solver's stack.
virtual void reset() override
Removes all assertions from the solver's stack.
virtual void add(storm::expressions::Expression const &assertion) override
Adds an assertion to the solver's stack.
virtual CheckResult checkWithAssumptions(std::set< storm::expressions::Expression > const &assumptions) override
Checks whether the conjunction of assertions that are currently on the solver's stack together with t...
virtual void pop() override
Pops a backtracking point from the solver's stack.
LabParser.cpp.
Definition cli.cpp:18
carl::Relation CompareRelation
carl::Variable RationalFunctionVariable