dReal4
forall_formula_evaluator.h
1 #pragma once
2 
3 #include <memory>
4 #include <ostream>
5 #include <vector>
6 
7 #include "dreal/solver/context.h"
8 #include "dreal/solver/formula_evaluator.h"
9 #include "dreal/solver/formula_evaluator_cell.h"
10 #include "dreal/solver/relational_formula_evaluator.h"
12 #include "dreal/util/box.h"
13 
14 namespace dreal {
15 
16 /// Evaluator for forall formulas.
17 ///
18 /// In the standard first-order logic semantics, A universally
19 /// quantified formula is evaluated to a Boolean value. Here, however,
20 /// we want to have a quantitative measure when a
21 /// universally-quantified formula is false. We return an error
22 /// interval in order to utilize it as a termination criteria in ICP
23 /// (Interval Constraint Propagation).
24 ///
25 /// Given `f = ∀y. [(e₁(x, y) ≥ 0) ∨ ... ∨ (eₙ(x, y) ≥ 0)]`, we check
26 /// if there is a counterexample of f. To prevent a spurious
27 /// counterexample, we check the satisfiability of the ε-strengthened
28 /// version of the negation of the nested formula, `strengthen((e₁(x,
29 /// y) < 0) ∧ ... ∧ (eₙ(x, y) < 0), ε)`, with delta = δ. There can be
30 /// two possible results for this query:
31 ///
32 /// - UNSAT: Return a zero error-interval, `[0, 0]`.
33 ///
34 /// - δ-SAT: Given a counter example `(a, b)`, evaluate `eᵢ(Iₓ, b)`
35 /// where `Iₓ` is the current interval assignment on x.
36 /// Returns `[0, maxᵢ{|eᵢ(Iₓ, b)|}]`.
37 ///
39  public:
40  // To use this class in multi multiple threads, it is required to provide the
41  // number of jobs.
42  ForallFormulaEvaluator(Formula f, double epsilon, double delta,
43  int number_of_jobs);
44 
45  /// Deleted copy constructor.
47 
48  /// Deleted move constructor.
50 
51  /// Deleted copy-assignment operator.
53 
54  /// Deleted move-assignment operator.
56 
57  /// Default destructor.
58  ~ForallFormulaEvaluator() override = default;
59 
60  FormulaEvaluationResult operator()(const Box& box) const override;
61 
62  std::ostream& Display(std::ostream& os) const override;
63 
64  const Variables& variables() const override;
65 
66  private:
67  Context& GetContext() const;
68 
69  std::vector<RelationalFormulaEvaluator> evaluators_;
70 
71  // To make this class thread-safe, it includes a vector of Contexts and each
72  // thread owns a unique Context instance.
73  mutable std::vector<Context> contexts_;
74 };
75 
76 } // namespace dreal
Context class that holds a set of constraints and provide Assert/Push/Pop/CheckSat functionalities...
Definition: context.h:23
Evaluator for forall formulas.
Definition: forall_formula_evaluator.h:38
Sum type of symbolic::Expression and symbolic::Formula.
Definition: api.cc:9
Base type for evaluator cell types.
Definition: formula_evaluator_cell.h:13
Represents the evaluation result of a constraint given a box.
Definition: formula_evaluator.h:14
Represents a n-dimensional interval vector.
Definition: box.h:17
FormulaEvaluationResult operator()(const Box &box) const override
Evaluates the constraint/formula with box.
Definition: forall_formula_evaluator.cc:85
This is the header file that we consolidate Drake&#39;s symbolic classes and expose them inside of dreal ...
Represents a set of variables.
Definition: symbolic_variables.h:25
~ForallFormulaEvaluator() override=default
Default destructor.
ForallFormulaEvaluator & operator=(const ForallFormulaEvaluator &)=delete
Deleted copy-assignment operator.
Represents a symbolic form of a first-order logic formula.
Definition: symbolic_formula.h:101