Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Z3SmtSolver.h
Go to the documentation of this file.
1#pragma once
2
3#include "storm-config.h"
6
7#ifdef STORM_HAVE_Z3
8#include <z3++.h>
9#include <z3.h>
10#endif
11
12namespace storm {
13namespace solver {
14class Z3SmtSolver : public SmtSolver {
15 public:
17 public:
18#ifdef STORM_HAVE_Z3
19 Z3ModelReference(storm::expressions::ExpressionManager const& manager, z3::model const& m, storm::adapters::Z3ExpressionAdapter& expressionAdapter);
20#endif
21 virtual bool getBooleanValue(storm::expressions::Variable const& variable) const override;
22 virtual int_fast64_t getIntegerValue(storm::expressions::Variable const& variable) const override;
23 virtual double getRationalValue(storm::expressions::Variable const& variable) const override;
24 virtual std::string toString() const override;
25
26 private:
27#ifdef STORM_HAVE_Z3
28 // The Z3 model out of which the information can be extracted.
29 z3::model model;
30
31 // The expression adapter that is used to translate the variable names.
32 storm::adapters::Z3ExpressionAdapter& expressionAdapter;
33#endif
34 };
35
36 public:
38 virtual ~Z3SmtSolver();
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
50 virtual void addNotCurrentModel(bool performSolverReset = true) override;
51
52 virtual CheckResult check() override;
53
54 virtual CheckResult checkWithAssumptions(storm::expressions::ExpressionSet const& assumptions) override;
55
56 virtual CheckResult checkWithAssumptions(std::initializer_list<storm::expressions::Expression> const& assumptions) override;
57
59
60 virtual std::shared_ptr<SmtSolver::ModelReference> getModel() override;
61
62 virtual std::vector<storm::expressions::SimpleValuation> allSat(std::vector<storm::expressions::Variable> const& important) override;
63
64 virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important,
65 std::function<bool(storm::expressions::SimpleValuation&)> const& callback) override;
66
67 virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important, std::function<bool(ModelReference&)> const& callback) override;
68
69 virtual std::vector<storm::expressions::Expression> getUnsatAssumptions() override;
70
71 virtual bool setTimeout(uint_fast64_t milliseconds) override;
72
73 virtual bool unsetTimeout() override;
74
75 virtual std::string getSmtLibString() const override;
76
77 private:
78#ifdef STORM_HAVE_Z3
85 storm::expressions::SimpleValuation convertZ3ModelToValuation(z3::model const& model);
86
87 // The context used by the solver.
88 std::unique_ptr<z3::context> context;
89
90 // The actual solver object.
91 std::unique_ptr<z3::solver> solver;
92
93 // An expression adapter that is used for translating the expression into Z3's format.
94 std::unique_ptr<storm::adapters::Z3ExpressionAdapter> expressionAdapter;
95
96 // A flag storing whether the last call to a check method provided aussumptions.
97 bool lastCheckAssumptions;
98
99 // The last result that was returned by any of the check methods.
100 CheckResult lastResult;
101#endif
102};
103} // namespace solver
104} // namespace storm
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:30
SmtSolver(storm::expressions::ExpressionManager &manager)
Constructs a new Smt solver with the given options.
Definition SmtSolver.cpp:17
CheckResult
possible check results
Definition SmtSolver.h:24
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 std::string getSmtLibString() const override
If supported by the solver, this function returns the current assertions in the SMT-LIB format.
Z3SmtSolver(storm::expressions::ExpressionManager &manager)
virtual std::vector< storm::expressions::SimpleValuation > allSat(std::vector< storm::expressions::Variable > const &important) override
Performs AllSat over the (provided) important atoms.
virtual CheckResult checkWithAssumptions(storm::expressions::ExpressionSet const &assumptions) override
Checks whether the conjunction of assertions that are currently on the solver's stack together with t...
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 addNotCurrentModel(bool performSolverReset=true) override
If supported by the solver, this function tells the SMT solver to produce a model different from the ...
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.
std::set< Expression, ExpressionComparator > ExpressionSet
Definition Expression.h:515