Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Cvc5SmtSolver.h
Go to the documentation of this file.
1#pragma once
2
3#include "storm-config.h"
6
7#ifdef STORM_HAVE_CVC5
8#include <cvc5/cvc5.h>
9#endif
10
11namespace storm::solver {
12class Cvc5SmtSolver : public SmtSolver {
13 public:
15 public:
26
27 virtual bool getBooleanValue(storm::expressions::Variable const& variable) const override;
28 virtual int_fast64_t getIntegerValue(storm::expressions::Variable const& variable) const override;
29 virtual double getRationalValue(storm::expressions::Variable const& variable) const override;
30 virtual std::string toString() const override;
31
32 private:
36 void checkVariable(storm::expressions::Variable const& variable) const;
37
38 // The values that the model assigns to the variables.
40 };
41
42 public:
44 virtual ~Cvc5SmtSolver();
45
46 virtual void push() override;
47
48 virtual void pop() override;
49
50 virtual void pop(uint_fast64_t n) override;
51
52 virtual void reset() override;
53
54 virtual void add(storm::expressions::Expression const& assertion) override;
55
56 virtual void addNotCurrentModel(bool performSolverReset = true) override;
57
58 virtual CheckResult check() override;
59
60 virtual CheckResult checkWithAssumptions(storm::expressions::ExpressionSet const& assumptions) override;
61
62 virtual CheckResult checkWithAssumptions(std::initializer_list<storm::expressions::Expression> const& assumptions) override;
63
65
66 virtual std::shared_ptr<SmtSolver::ModelReference> getModel() override;
67
68 virtual std::vector<storm::expressions::SimpleValuation> allSat(std::vector<storm::expressions::Variable> const& important) override;
69
70 virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important,
71 std::function<bool(storm::expressions::SimpleValuation&)> const& callback) override;
72
73 virtual uint_fast64_t allSat(std::vector<storm::expressions::Variable> const& important, std::function<bool(ModelReference&)> const& callback) override;
74
75 virtual std::vector<storm::expressions::Expression> getUnsatAssumptions() override;
76
77 virtual bool setTimeout(uint_fast64_t milliseconds) override;
78
79 virtual bool unsetTimeout() override;
80
81 private:
82#ifdef STORM_HAVE_CVC5
86 SmtSolver::CheckResult translateResult(cvc5::Result const& result) const;
87
91 std::unordered_map<storm::expressions::Variable, cvc5::Term> collectVariableValues() const;
92
100 storm::expressions::SimpleValuation collectModelAsValuation() const;
101
108 cvc5::Term createModelExpression(std::vector<storm::expressions::Variable> const& variables) const;
109
110 // The manager that terms and sorts are built with, which is also passed to the cvc5::Solver constructor. It
111 // is declared before the solver so that it outlives it, as the terms of the solver refer to it.
112 std::unique_ptr<cvc5::TermManager> termManager;
113
114 // The actual solver object.
115 std::unique_ptr<cvc5::Solver> solver;
116
117 // An expression adapter that is used for translating the expression into cvc5's format.
118 std::unique_ptr<storm::adapters::Cvc5ExpressionAdapter> expressionAdapter;
119
120 // A flag storing whether the last call to a check method provided assumptions.
121 bool lastCheckAssumptions;
122
123 // The last result that was returned by any of the check methods.
124 CheckResult lastResult;
125#endif
126};
127} // namespace storm::solver
This class is responsible for managing a set of typed variables and all expressions using these varia...
A simple implementation of the valuation interface.
virtual double getRationalValue(storm::expressions::Variable const &variable) const override
Cvc5ModelReference(storm::expressions::ExpressionManager const &manager, storm::expressions::SimpleValuation variableValues)
Creates a new model reference that provides access to the values that the given model assigns.
virtual bool getBooleanValue(storm::expressions::Variable const &variable) const override
virtual int_fast64_t getIntegerValue(storm::expressions::Variable const &variable) const override
virtual std::string toString() const override
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 push() override
Pushes a backtracking point on the solver's stack.
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 storm::expressions::SimpleValuation getModelAsValuation() override
If the last call to check() or checkWithAssumptions() returned Sat, this method retrieves a model tha...
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 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 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 add(storm::expressions::Expression const &assertion) override
Adds an assertion to 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 pop() override
Pops a backtracking point from the solver's stack.
virtual bool unsetTimeout() override
If supported by the solver, this unsets a previous timeout.
Cvc5SmtSolver(storm::expressions::ExpressionManager &manager)
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.
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::set< Expression, ExpressionComparator > ExpressionSet
Definition Expression.h:515