Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
MathsatSmtSolver.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/container/flat_map.hpp>
4#include "storm-config.h"
7
8#ifdef STORM_HAVE_MATHSAT
9#include <mathsat.h>
10#endif
11
12namespace storm {
13namespace solver {
15 public:
34
35#ifdef STORM_HAVE_MATHSAT
36 class MathsatAllsatModelReference : public SmtSolver::ModelReference {
37 public:
38 MathsatAllsatModelReference(storm::expressions::ExpressionManager const& manager, msat_env const& env, msat_term* model,
39 std::unordered_map<storm::expressions::Variable, uint_fast64_t> const& variableNameToSlotMapping);
40
41 virtual bool getBooleanValue(storm::expressions::Variable const& variable) const override;
42 virtual int_fast64_t getIntegerValue(storm::expressions::Variable const& variable) const override;
43 virtual double getRationalValue(storm::expressions::Variable const& variable) const override;
44 virtual std::string toString() const override;
45
46 private:
47 msat_env const& env;
48 msat_term* model;
49 std::unordered_map<storm::expressions::Variable, uint_fast64_t> const& variableToSlotMapping;
50 };
51#endif
52
53#ifdef STORM_HAVE_MATHSAT
54 class MathsatModelReference : public SmtSolver::ModelReference {
55 public:
56 MathsatModelReference(storm::expressions::ExpressionManager const& manager, msat_env const& env,
57 storm::adapters::MathsatExpressionAdapter& expressionAdapter);
58
59 virtual bool getBooleanValue(storm::expressions::Variable const& variable) const override;
60 virtual int_fast64_t getIntegerValue(storm::expressions::Variable const& variable) const override;
61 virtual double getRationalValue(storm::expressions::Variable const& variable) const override;
62 virtual std::string toString() const override;
63
64 private:
65 msat_env const& env;
66 storm::adapters::MathsatExpressionAdapter& expressionAdapter;
67 };
68#endif
69
70 MathsatSmtSolver(storm::expressions::ExpressionManager& manager, Options const& options = Options());
71
72 virtual ~MathsatSmtSolver();
73
74 virtual void push() override;
75
76 virtual void pop() override;
77
78 virtual void pop(uint_fast64_t n) override;
79
80 virtual void reset() override;
81
82 virtual void add(storm::expressions::Expression const& assertion) override;
83
84 virtual CheckResult check() override;
85
86 virtual CheckResult checkWithAssumptions(std::set<storm::expressions::Expression> const& assumptions) override;
87
88 virtual CheckResult checkWithAssumptions(std::initializer_list<storm::expressions::Expression> const& assumptions) override;
89
91
92 virtual std::shared_ptr<SmtSolver::ModelReference> getModel() override;
93
94 virtual std::vector<storm::expressions::SimpleValuation> allSat(std::vector<storm::expressions::Variable> const& important) override;
95
96 virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important,
97 std::function<bool(storm::expressions::SimpleValuation&)> const& callback) override;
98
99 virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important, std::function<bool(ModelReference&)> const& callback) override;
100
101 virtual std::vector<storm::expressions::Expression> getUnsatAssumptions() override;
102
103 virtual void setInterpolationGroup(uint_fast64_t group) override;
104
105 virtual storm::expressions::Expression getInterpolant(std::vector<uint_fast64_t> const& groupsA) override;
106
107 private:
108 storm::expressions::SimpleValuation convertMathsatModelToValuation();
109
110#ifdef STORM_HAVE_MATHSAT
111 // The MathSAT environment.
112 msat_env env;
113
114 // The expression adapter used to translate expressions to MathSAT's format. This has to be a pointer, since
115 // it must be initialized after creating the environment, but the adapter class has no default constructor.
116 std::unique_ptr<storm::adapters::MathsatExpressionAdapter> expressionAdapter;
117#endif
118
119 // A flag storing whether the last call was a check involving assumptions.
120 bool lastCheckAssumptions;
121
122 // The result of the last call to any of the check methods.
123 CheckResult lastResult;
124
125 // A mapping of interpolation group indices to their MathSAT identifier.
126 typedef boost::container::flat_map<uint_fast64_t, int> InterpolationGroupMapType;
127 InterpolationGroupMapType interpolationGroups;
128};
129} // namespace solver
130} // 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.
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.
MathsatSmtSolver(storm::expressions::ExpressionManager &manager, Options const &options=Options())
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: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
std::string toString(GurobiSolverMethod const &method)
Yields a string representation of the GurobiSolverMethod.