Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Z3SmtSolver.h
Go to the documentation of this file.
1#ifndef STORM_SOLVER_Z3SMTSOLVER
2#define STORM_SOLVER_Z3SMTSOLVER
3
4#include "storm-config.h"
7
8#ifdef STORM_HAVE_Z3
9#include "z3++.h"
10#include "z3.h"
11#endif
12
13namespace storm {
14namespace solver {
15class Z3SmtSolver : public SmtSolver {
16 public:
18 public:
19#ifdef STORM_HAVE_Z3
20 Z3ModelReference(storm::expressions::ExpressionManager const& manager, z3::model const& m, storm::adapters::Z3ExpressionAdapter& expressionAdapter);
21#endif
22 virtual bool getBooleanValue(storm::expressions::Variable const& variable) const override;
23 virtual int_fast64_t getIntegerValue(storm::expressions::Variable const& variable) const override;
24 virtual double getRationalValue(storm::expressions::Variable const& variable) const override;
25 virtual std::string toString() const override;
26
27 private:
28#ifdef STORM_HAVE_Z3
29 // The Z3 model out of which the information can be extracted.
30 z3::model model;
31
32 // The expression adapter that is used to translate the variable names.
33 storm::adapters::Z3ExpressionAdapter& expressionAdapter;
34#endif
35 };
36
37 public:
39 virtual ~Z3SmtSolver();
40
41 virtual void push() override;
42
43 virtual void pop() override;
44
45 virtual void pop(uint_fast64_t n) override;
46
47 virtual void reset() override;
48
49 virtual void add(storm::expressions::Expression const& assertion) override;
50
51 virtual CheckResult check() override;
52
53 virtual CheckResult checkWithAssumptions(std::set<storm::expressions::Expression> const& assumptions) override;
54
55#ifndef WINDOWS
56 virtual CheckResult checkWithAssumptions(std::initializer_list<storm::expressions::Expression> const& assumptions) override;
57#endif
58
60
61 virtual std::shared_ptr<SmtSolver::ModelReference> getModel() override;
62
63 virtual std::vector<storm::expressions::SimpleValuation> allSat(std::vector<storm::expressions::Variable> const& important) override;
64
65 virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important,
66 std::function<bool(storm::expressions::SimpleValuation&)> const& callback) override;
67
68 virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important, std::function<bool(ModelReference&)> const& callback) override;
69
70 virtual std::vector<storm::expressions::Expression> getUnsatAssumptions() override;
71
72 virtual bool setTimeout(uint_fast64_t milliseconds) override;
73
74 virtual bool unsetTimeout() override;
75
76 virtual std::string getSmtLibString() const override;
77
78 private:
79#ifdef STORM_HAVE_Z3
86 storm::expressions::SimpleValuation convertZ3ModelToValuation(z3::model const& model);
87
88 // The context used by the solver.
89 std::unique_ptr<z3::context> context;
90
91 // The actual solver object.
92 std::unique_ptr<z3::solver> solver;
93
94 // An expression adapter that is used for translating the expression into Z3's format.
95 std::unique_ptr<storm::adapters::Z3ExpressionAdapter> expressionAdapter;
96
97 // A flag storing whether the last call to a check method provided aussumptions.
98 bool lastCheckAssumptions;
99
100 // The last result that was returned by any of the check methods.
101 CheckResult lastResult;
102#endif
103};
104} // namespace solver
105} // namespace storm
106#endif // STORM_SOLVER_Z3SMTSOLVER
This class is responsible for managing a set of typed variables and all expressions using these varia...
A simple implementation of the valuation interface.
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
virtual uint_fast64_t allSat(std::vector< storm::expressions::Variable > const &important, std::function< bool(ModelReference &)> const &callback) override
Performs AllSat over the (provided) important atoms.
virtual void add(storm::expressions::Expression const &assertion) override
Adds an assertion to the solver's stack.
virtual bool unsetTimeout() override
If supported by the solver, this unsets a previous timeout.
virtual std::shared_ptr< SmtSolver::ModelReference > getModel() override
If the last call to check() or checkWithAssumptions() returned Sat, this method retrieves a model tha...
virtual storm::expressions::SimpleValuation getModelAsValuation() override
If the last call to check() or checkWithAssumptions() returned Sat, this method retrieves a model tha...
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 std::string getSmtLibString() const override
If supported by the solver, this function returns the current assertions in the SMT-LIB format.
virtual std::vector< storm::expressions::SimpleValuation > allSat(std::vector< storm::expressions::Variable > const &important) override
Performs AllSat over the (provided) important atoms.
virtual void reset() override
Removes all assertions from the solver's stack.
virtual void push() override
Pushes a backtracking point on the solver's stack.
virtual std::vector< storm::expressions::Expression > getUnsatAssumptions() override
If the last call to checkWithAssumptions() returned Unsat, this function can be used to retrieve a su...
virtual bool setTimeout(uint_fast64_t milliseconds) override
If supported by the solver, this will limit all subsequent satisfiability queries to the given number...
virtual void pop() override
Pops a backtracking point from the solver's stack.
virtual CheckResult check() override
Checks whether the conjunction of assertions that are currently on the solver's stack is satisfiable.
LabParser.cpp.
Definition cli.cpp:18