dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
symbolic.h
1
14#pragma once
15
16#include <functional>
17#include <ostream>
18#include <set>
19#include <string>
20#include <vector>
21
22// From drake
23// IWYU pragma: begin_exports
24#include "dlinear/symbolic/symbolic_environment.h"
25#include "dlinear/symbolic/symbolic_expression.h"
26#include "dlinear/symbolic/symbolic_expression_cell.h"
27#include "dlinear/symbolic/symbolic_expression_visitor.h"
28#include "dlinear/symbolic/symbolic_formula.h"
29#include "dlinear/symbolic/symbolic_formula_visitor.h"
30#include "dlinear/symbolic/symbolic_variables.h"
31// IWYU pragma: end_exports
32
33// From dlinear
34#include "dlinear/symbolic/hash.h"
35#include "dlinear/symbolic/literal.h"
36
37namespace dlinear {
38
39using drake::symbolic::Environment;
40using drake::symbolic::Expression;
41using drake::symbolic::ExpressionAddFactory;
42using drake::symbolic::ExpressionKind;
43using drake::symbolic::Formula;
44using drake::symbolic::FormulaKind;
45using drake::symbolic::Variables;
46using drake::symbolic::VisitExpression;
47using drake::symbolic::VisitFormula;
48
56FormulaKind operator-(FormulaKind kind);
57
59Formula imply(const Formula &f1, const Formula &f2);
61Formula imply(const Variable &v, const Formula &f);
63Formula imply(const Formula &f, const Variable &v);
65Formula imply(const Variable &v1, const Variable &v2);
66
68Formula iff(const Formula &f1, const Formula &f2);
70Formula iff(const Variable &v, const Formula &f);
72Formula iff(const Formula &f, const Variable &v);
74Formula iff(const Variable &v1, const Variable &v2);
75
83std::set<Formula> map(const std::set<Formula> &formulas, const std::function<Formula(const Formula &)> &func);
84
90bool is_atomic(const Formula &f);
91
98bool is_clause(const Formula &f);
99
107std::set<Formula> get_clauses(const Formula &f);
108
114bool is_cnf(const Formula &f);
115
124bool HaveIntersection(const Variables &variables1, const Variables &variables2);
125
132Formula DeltaStrengthen(const Formula &f, double delta);
133
140Formula DeltaWeaken(const Formula &f, double delta);
141
147bool IsDifferentiable(const Formula &f);
148
154bool IsDifferentiable(const Expression &e);
155
164Formula make_conjunction(const std::vector<Formula> &formulas);
165
174Formula make_disjunction(const std::vector<Formula> &formulas);
175
187std::vector<Variable> CreateVector(const std::string &prefix, int size,
189
192 EQ,
193 NEQ,
194 GT,
195 GEQ,
196 LT,
197 LEQ,
198};
199
206
207std::ostream &operator<<(std::ostream &os, RelationalOperator op);
208
209std::ostream &operator<<(std::ostream &os, const FormulaKind &kind);
210
211std::ostream &operator<<(std::ostream &os, const ExpressionKind &kind);
212
213} // namespace dlinear
214
215#ifdef DLINEAR_INCLUDE_FMT
216
217#include "dlinear/util/logging.h"
218
219OSTREAM_FORMATTER(dlinear::Expression)
220OSTREAM_FORMATTER(dlinear::Formula)
221OSTREAM_FORMATTER(dlinear::Variables)
222OSTREAM_FORMATTER(dlinear::RelationalOperator)
223OSTREAM_FORMATTER(dlinear::FormulaKind)
224OSTREAM_FORMATTER(dlinear::ExpressionKind)
225
226#endif
Represents a symbolic form of an expression.
Represents a symbolic form of a first-order logic formula.
Type
Supported types of symbolic variables.
@ CONTINUOUS
A CONTINUOUS variable takes a mpq_class value.
Represents a set of variables.
Global namespace for the dlinear library.
Formula make_conjunction(const std::vector< Formula > &formulas)
Make conjunction of formulas.
Definition symbolic.cpp:485
Formula DeltaWeaken(const Formula &f, const double delta)
Weaken the input formula $p f by delta.
Definition symbolic.cpp:476
std::set< Formula > map(const std::set< Formula > &formulas, const std::function< Formula(const Formula &)> &func)
Given formulas = {f₁, ..., fₙ} and a func : Formula → Formula, map(formulas, func) returns a set {fun...
Definition symbolic.cpp:47
std::set< Formula > get_clauses(const Formula &f)
Returns the set of clauses in f.
Definition symbolic.cpp:98
bool is_cnf(const Formula &f)
Check if f is in CNF form.
Definition symbolic.cpp:110
RelationalOperator
Relational operators are used in formulas.
Definition symbolic.h:191
bool IsDifferentiable(const Formula &f)
Check if the formula f is symbolic-differentiable.
Definition symbolic.cpp:481
LpColBound operator!(LpColBound bound)
Invert the bound with delta == 0.
Formula iff(const Formula &f1, const Formula &f2)
Return a formula f1 ⇔ f2.
Definition symbolic.cpp:39
Formula imply(const Formula &f1, const Formula &f2)
Return a formula f1 ⇒ f2.
Definition symbolic.cpp:34
Formula DeltaStrengthen(const Formula &f, const double delta)
Strengthen the input formula $p f by delta.
Definition symbolic.cpp:470
Formula make_disjunction(const std::vector< Formula > &formulas)
Make disjunction of formulas.
Definition symbolic.cpp:493
LpColBound operator-(LpColBound bound)
Invert the bound with delta > 0.
std::vector< Variable > CreateVector(const std::string &prefix, const int size, const Variable::Type type)
Creates a vector of variables of type whose size is size.
Definition symbolic.cpp:501
bool is_clause(const Formula &f)
Check if f is a clause.
Definition symbolic.cpp:78
bool HaveIntersection(const Variables &variables1, const Variables &variables2)
Check if the intersection of variables1 and variables2 is non-empty.
Definition symbolic.cpp:126
bool is_atomic(const Formula &f)
Check if f is atomic.
Definition symbolic.cpp:53
@ GT
Greater than.