dReal4
theory_solver.h
1 #pragma once
2 
3 #include <memory>
4 #include <set>
5 #include <unordered_map>
6 #include <vector>
7 
8 #include "dreal/contractor/contractor.h"
9 #include "dreal/solver/config.h"
10 #include "dreal/solver/formula_evaluator.h"
11 #include "dreal/solver/icp.h"
13 #include "dreal/util/box.h"
14 #include "dreal/util/optional.h"
15 
16 namespace dreal {
17 
18 /// Theory solver for nonlinear theory over the Reals.
19 class TheorySolver {
20  public:
21  TheorySolver() = delete;
22  explicit TheorySolver(const Config& config);
23 
24  /// Checks consistency. Returns true if there is a satisfying
25  /// assignment. Otherwise, return false.
26  bool CheckSat(const Box& box, const std::vector<Formula>& assertions);
27 
28  /// Gets a satisfying Model.
29  const Box& GetModel() const;
30 
31  /// Gets a list of used constraints.
32  const std::set<Formula>& GetExplanation() const;
33 
34  private:
35  // Builds a contractor using @p box and @p assertions. It returns
36  // nullopt if it detects an empty box while building a contractor.
37  //
38  // @note This method updates @p box as it calls FilterAssertion
39  // function.
40  optional<Contractor> BuildContractor(const std::vector<Formula>& assertions,
41  ContractorStatus* contractor_status);
42  std::vector<FormulaEvaluator> BuildFormulaEvaluator(
43  const std::vector<Formula>& assertions);
44 
45  const Config& config_;
46  std::unique_ptr<Icp> icp_;
47  Box model_;
48  std::set<Formula> explanation_;
49  std::unordered_map<Formula, Contractor> contractor_cache_;
50  std::unordered_map<Formula, FormulaEvaluator> formula_evaluator_cache_;
51 };
52 
53 } // namespace dreal
bool CheckSat(const Box &box, const std::vector< Formula > &assertions)
Checks consistency.
Definition: theory_solver.cc:184
Sum type of symbolic::Expression and symbolic::Formula.
Definition: api.cc:9
Theory solver for nonlinear theory over the Reals.
Definition: theory_solver.h:19
const Box & GetModel() const
Gets a satisfying Model.
Definition: theory_solver.cc:214
Represents a n-dimensional interval vector.
Definition: box.h:17
Definition: config.h:12
This is the header file that we consolidate Drake&#39;s symbolic classes and expose them inside of dreal ...
Contractor status.
Definition: contractor_status.h:13
const std::set< Formula > & GetExplanation() const
Gets a list of used constraints.
Definition: theory_solver.cc:219