Storm 1.11.1.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SmtlibSmtSolver.h
Go to the documentation of this file.
1#pragma once
2
3#include <fstream>
4#include <iostream>
5
6#include "storm-config.h"
10
11namespace storm {
12namespace solver {
19class SmtlibSmtSolver : public SmtSolver {
20 public:
22 public:
24 virtual bool getBooleanValue(storm::expressions::Variable const& variable) const override;
25 virtual int_fast64_t getIntegerValue(storm::expressions::Variable const& variable) const override;
26 virtual double getRationalValue(storm::expressions::Variable const& variable) const override;
27 virtual std::string toString() const override;
28 };
29
30 public:
36 SmtlibSmtSolver(storm::expressions::ExpressionManager& manager, bool useCarlExpressions = false);
37 virtual ~SmtlibSmtSolver();
38
39 virtual void push() override;
40
41 virtual void pop() override;
42
43 virtual void pop(uint_fast64_t n) override;
44
45 virtual void reset() override;
46
47 virtual void add(storm::expressions::Expression const& assertion) override;
48
49 // adds the constraint "leftHandSide relation rightHandSide"
50 virtual void add(storm::RationalFunction const& leftHandSide, storm::CompareRelation const& relation,
51 storm::RationalFunction const& rightHandSide = storm::RationalFunction(0));
52
53 // asserts that the given variable has the given value. The variable should have type 'bool'
54 void add(storm::RationalFunctionVariable const& variable, bool value);
55
56 virtual CheckResult check() override;
57
58 virtual CheckResult checkWithAssumptions(std::set<storm::expressions::Expression> const& assumptions) override;
59
60 virtual CheckResult checkWithAssumptions(std::initializer_list<storm::expressions::Expression> const& assumptions) override;
61
62 bool isNeedsRestart() const;
63
64 // Todo: some of these might be added in the future
65 // virtual storm::expressions::SimpleValuation getModelAsValuation() override;
66
67 // virtual std::shared_ptr<SmtSolver::ModelReference> getModel() override;
68
69 // virtual std::vector<storm::expressions::SimpleValuation> allSat(std::vector<storm::expressions::Variable> const& important) override;
70
71 // virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important, std::function<bool(storm::expressions::SimpleValuation&)>
72 // const& callback) override;
73
74 // virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important, std::function<bool(ModelReference&)> const& callback) override;
75
76 // virtual std::vector<storm::expressions::Expression> getUnsatAssumptions() override;
77
78 private:
83 void init();
84
90 void writeCommand(std::string smt2Command, bool expectSuccess);
91
97 std::vector<std::string> readSolverOutput(bool waitForOutput = true);
98
108 void checkForErrorMessage(const std::string message);
109
110 // descriptors for the pipe from and to the solver
111 int toSolver;
112 int fromSolver;
113 // A flag storing the Process ID of the solver. If this is zero, then the solver is not running
114 pid_t processIdOfSolver;
115
116 // a filestream where the commands that we send to the solver will be stored (can be used for debugging purposes)
117 std::ofstream commandFile;
118
119 bool isCommandFileOpen;
120
121 // An expression adapter that is used for translating the expression into Smt2's format.
122 std::unique_ptr<storm::adapters::Smt2ExpressionAdapter> expressionAdapter;
123
124 // A flag storing whether the last call to a check method provided aussumptions.
125 // bool lastCheckAssumptions;
126
127 // The last result that was returned by any of the check methods.
128 // CheckResult lastResult;
129
130 // A flag that states whether we want to use carl expressions.
131 bool useCarlExpressions;
132
133 // A flag that states whether to use readable variable names
134 bool useReadableVarNames = true;
135
136 // A flag that states whether some error has occured
137 bool needsRestart = false;
138};
139} // namespace solver
140} // namespace storm
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 add(storm::RationalFunction const &leftHandSide, storm::CompareRelation const &relation, storm::RationalFunction const &rightHandSide=storm::RationalFunction(0))
void add(storm::RationalFunctionVariable const &variable, bool value)
virtual void pop() override
Pops a backtracking point from the solver's stack.
carl::Relation CompareRelation
carl::Variable RationalFunctionVariable