Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
MathsatSmtSolver.h
Go to the documentation of this file.
1#ifndef STORM_SOLVER_MATHSATSMTSOLVER
2#define STORM_SOLVER_MATHSATSMTSOLVER
3
4#include <boost/container/flat_map.hpp>
5#include "storm-config.h"
8
9#ifdef STORM_HAVE_MSAT
10#include "mathsat.h"
11#endif
12
13namespace storm {
14namespace solver {
16 public:
35
36#ifdef STORM_HAVE_MSAT
37 class MathsatAllsatModelReference : public SmtSolver::ModelReference {
38 public:
39 MathsatAllsatModelReference(storm::expressions::ExpressionManager const& manager, msat_env const& env, msat_term* model,
40 std::unordered_map<storm::expressions::Variable, uint_fast64_t> const& variableNameToSlotMapping);
41
42 virtual bool getBooleanValue(storm::expressions::Variable const& variable) const override;
43 virtual int_fast64_t getIntegerValue(storm::expressions::Variable const& variable) const override;
44 virtual double getRationalValue(storm::expressions::Variable const& variable) const override;
45 virtual std::string toString() const override;
46
47 private:
48 msat_env const& env;
49 msat_term* model;
50 std::unordered_map<storm::expressions::Variable, uint_fast64_t> const& variableToSlotMapping;
51 };
52#endif
53
54#ifdef STORM_HAVE_MSAT
55 class MathsatModelReference : public SmtSolver::ModelReference {
56 public:
57 MathsatModelReference(storm::expressions::ExpressionManager const& manager, msat_env const& env,
58 storm::adapters::MathsatExpressionAdapter& expressionAdapter);
59
60 virtual bool getBooleanValue(storm::expressions::Variable const& variable) const override;
61 virtual int_fast64_t getIntegerValue(storm::expressions::Variable const& variable) const override;
62 virtual double getRationalValue(storm::expressions::Variable const& variable) const override;
63 virtual std::string toString() const override;
64
65 private:
66 msat_env const& env;
67 storm::adapters::MathsatExpressionAdapter& expressionAdapter;
68 };
69#endif
70
71 MathsatSmtSolver(storm::expressions::ExpressionManager& manager, Options const& options = Options());
72
73 virtual ~MathsatSmtSolver();
74
75 virtual void push() override;
76
77 virtual void pop() override;
78
79 virtual void pop(uint_fast64_t n) override;
80
81 virtual void reset() override;
82
83 virtual void add(storm::expressions::Expression const& assertion) override;
84
85 virtual CheckResult check() override;
86
87 virtual CheckResult checkWithAssumptions(std::set<storm::expressions::Expression> const& assumptions) override;
88
89#ifndef WINDOWS
90 virtual CheckResult checkWithAssumptions(std::initializer_list<storm::expressions::Expression> const& assumptions) override;
91#endif
92
94
95 virtual std::shared_ptr<SmtSolver::ModelReference> getModel() override;
96
97 virtual std::vector<storm::expressions::SimpleValuation> allSat(std::vector<storm::expressions::Variable> const& important) override;
98
99 virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important,
100 std::function<bool(storm::expressions::SimpleValuation&)> const& callback) override;
101
102 virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important, std::function<bool(ModelReference&)> const& callback) override;
103
104 virtual std::vector<storm::expressions::Expression> getUnsatAssumptions() override;
105
106 virtual void setInterpolationGroup(uint_fast64_t group) override;
107
108 virtual storm::expressions::Expression getInterpolant(std::vector<uint_fast64_t> const& groupsA) override;
109
110 private:
111 storm::expressions::SimpleValuation convertMathsatModelToValuation();
112
113#ifdef STORM_HAVE_MSAT
114 // The MathSAT environment.
115 msat_env env;
116
117 // The expression adapter used to translate expressions to MathSAT's format. This has to be a pointer, since
118 // it must be initialized after creating the environment, but the adapter class has no default constructor.
119 std::unique_ptr<storm::adapters::MathsatExpressionAdapter> expressionAdapter;
120#endif
121
122 // A flag storing whether the last call was a check involving assumptions.
123 bool lastCheckAssumptions;
124
125 // The result of the last call to any of the check methods.
126 CheckResult lastResult;
127
128 // A mapping of interpolation group indices to their MathSAT identifier.
129 typedef boost::container::flat_map<uint_fast64_t, int> InterpolationGroupMapType;
130 InterpolationGroupMapType interpolationGroups;
131};
132} // namespace solver
133} // namespace storm
134#endif // STORM_SOLVER_MATHSATSMTSOLVER
This class is responsible for managing a set of typed variables and all expressions using these varia...
A simple implementation of the valuation interface.
A class that captures options that may be passed to the Mathsat solver.
Options(bool enableModelGeneration=true, bool enableUnsatCoreGeneration=false, bool enableInterpolantGeneration=false)
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 storm::expressions::Expression getInterpolant(std::vector< uint_fast64_t > const &groupsA) override
If the last call to check() returned Unsat, the solver has been instantiated with support for interpo...
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 void add(storm::expressions::Expression const &assertion) override
Adds an assertion to the solver's stack.
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 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.
virtual void reset() override
Removes all assertions from the solver's stack.
virtual std::vector< storm::expressions::SimpleValuation > allSat(std::vector< storm::expressions::Variable > const &important) override
Performs AllSat over the (provided) important atoms.
virtual void push() override
Pushes a backtracking point on 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 storm::expressions::SimpleValuation getModelAsValuation() override
If the last call to check() or checkWithAssumptions() returned Sat, this method retrieves a model tha...
virtual void setInterpolationGroup(uint_fast64_t group) override
Sets the current interpolation group.
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
LabParser.cpp.
Definition cli.cpp:18