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"
11
#include "
dreal/symbolic/symbolic.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
///
38
class
ForallFormulaEvaluator
:
public
FormulaEvaluatorCell
{
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.
46
ForallFormulaEvaluator
(
const
ForallFormulaEvaluator
&) =
delete
;
47
48
/// Deleted move constructor.
49
ForallFormulaEvaluator
(
ForallFormulaEvaluator
&&) =
delete
;
50
51
/// Deleted copy-assignment operator.
52
ForallFormulaEvaluator
&
operator=
(
const
ForallFormulaEvaluator
&) =
delete
;
53
54
/// Deleted move-assignment operator.
55
ForallFormulaEvaluator
&
operator=
(
ForallFormulaEvaluator
&&) =
delete
;
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
dreal::Context
Context class that holds a set of constraints and provide Assert/Push/Pop/CheckSat functionalities...
Definition:
context.h:23
dreal::ForallFormulaEvaluator
Evaluator for forall formulas.
Definition:
forall_formula_evaluator.h:38
dreal
Sum type of symbolic::Expression and symbolic::Formula.
Definition:
api.cc:9
dreal::FormulaEvaluatorCell
Base type for evaluator cell types.
Definition:
formula_evaluator_cell.h:13
dreal::FormulaEvaluationResult
Represents the evaluation result of a constraint given a box.
Definition:
formula_evaluator.h:14
dreal::Box
Represents a n-dimensional interval vector.
Definition:
box.h:17
dreal::ForallFormulaEvaluator::operator()
FormulaEvaluationResult operator()(const Box &box) const override
Evaluates the constraint/formula with box.
Definition:
forall_formula_evaluator.cc:85
symbolic.h
This is the header file that we consolidate Drake's symbolic classes and expose them inside of dreal ...
dreal::drake::symbolic::Variables
Represents a set of variables.
Definition:
symbolic_variables.h:25
dreal::ForallFormulaEvaluator::~ForallFormulaEvaluator
~ForallFormulaEvaluator() override=default
Default destructor.
dreal::ForallFormulaEvaluator::operator=
ForallFormulaEvaluator & operator=(const ForallFormulaEvaluator &)=delete
Deleted copy-assignment operator.
dreal::drake::symbolic::Formula
Represents a symbolic form of a first-order logic formula.
Definition:
symbolic_formula.h:101
dreal
solver
forall_formula_evaluator.h
Generated by
1.8.13