10 #include "dreal/symbolic/symbolic_environment.h" 11 #include "dreal/symbolic/symbolic_expression.h" 12 #include "dreal/symbolic/symbolic_formula.h" 13 #include "dreal/symbolic/symbolic_variable.h" 14 #include "dreal/symbolic/symbolic_variables.h" 29 ExpressionKind
get_kind()
const {
return kind_; }
66 const FormulaSubstitution& formula_subst) = 0;
75 virtual std::ostream&
Display(std::ostream& os)
const = 0;
79 return atomic_load_explicit(&rc_, std::memory_order_acquire);
108 const ExpressionKind kind_{};
109 const size_t hash_{};
110 const bool is_polynomial_{
false};
111 const bool include_ite_{
false};
115 mutable std::atomic<unsigned> rc_{0};
116 void increase_rc()
const {
117 atomic_fetch_add_explicit(&rc_, 1U, std::memory_order_relaxed);
119 void decrease_rc()
const {
120 if (atomic_fetch_sub_explicit(&rc_, 1U, std::memory_order_acq_rel) == 1U) {
161 virtual double DoEvaluate(
double v)
const = 0;
204 virtual double DoEvaluate(
double v1,
double v2)
const = 0;
218 const Variable& get_variable()
const {
return var_; }
224 const FormulaSubstitution& formula_subst)
override;
226 std::ostream&
Display(std::ostream& os)
const override;
236 double get_value()
const {
return v_; }
242 const FormulaSubstitution& formula_subst)
override;
244 std::ostream&
Display(std::ostream& os)
const override;
259 double get_lb()
const {
return lb_; }
260 double get_ub()
const {
return ub_; }
261 double get_value()
const {
return use_lb_as_representative_ ? lb_ : ub_; }
267 const FormulaSubstitution& formula_subst)
override;
269 std::ostream&
Display(std::ostream& os)
const override;
274 const bool use_lb_as_representative_{};
286 const FormulaSubstitution& formula_subst)
override;
288 std::ostream&
Display(std::ostream& os)
const override;
309 std::map<Expression, double> expr_to_coeff_map);
315 const FormulaSubstitution& formula_subst)
override;
317 std::ostream&
Display(std::ostream& os)
const override;
322 return expr_to_coeff_map_;
329 return expr_to_coeff_map_;
334 const std::map<Expression, double>& expr_to_coeff_map);
335 std::ostream& DisplayTerm(std::ostream& os,
bool print_plus,
double coeff,
339 std::map<Expression, double> expr_to_coeff_map_;
364 std::map<Expression, double> expr_to_coeff_map);
406 const std::map<Expression, double>& expr_to_coeff_map);
408 bool get_expression_is_called_{
false};
409 double constant_{0.0};
410 std::map<Expression, double> expr_to_coeff_map_;
430 std::map<Expression, Expression> base_to_exponent_map);
436 const FormulaSubstitution& formula_subst)
override;
438 std::ostream&
Display(std::ostream& os)
const override;
443 return base_to_exponent_map_;
450 return base_to_exponent_map_;
455 const std::map<Expression, Expression>& base_to_exponent_map);
456 std::ostream& DisplayTerm(std::ostream& os,
bool print_mul,
461 std::map<Expression, Expression> base_to_exponent_map_;
486 std::map<Expression, Expression> base_to_exponent_map);
527 const std::map<Expression, Expression>& base_to_exponent_map);
529 bool get_expression_is_called_{
false};
530 double constant_{1.0};
531 std::map<Expression, Expression> base_to_exponent_map_;
540 const FormulaSubstitution& formula_subst)
override;
542 std::ostream&
Display(std::ostream& os)
const override;
545 double DoEvaluate(
double v1,
double v2)
const override;
554 const FormulaSubstitution& formula_subst)
override;
556 std::ostream&
Display(std::ostream& os)
const override;
562 static void check_domain(
double v);
563 double DoEvaluate(
double v)
const override;
572 const FormulaSubstitution& formula_subst)
override;
574 std::ostream&
Display(std::ostream& os)
const override;
579 double DoEvaluate(
double v)
const override;
589 const FormulaSubstitution& formula_subst)
override;
591 std::ostream&
Display(std::ostream& os)
const override;
594 double DoEvaluate(
double v)
const override;
603 const FormulaSubstitution& formula_subst)
override;
605 std::ostream&
Display(std::ostream& os)
const override;
611 static void check_domain(
double v);
612 double DoEvaluate(
double v)
const override;
621 const FormulaSubstitution& formula_subst)
override;
623 std::ostream&
Display(std::ostream& os)
const override;
630 static void check_domain(
double v1,
double v2);
631 double DoEvaluate(
double v1,
double v2)
const override;
640 const FormulaSubstitution& formula_subst)
override;
642 std::ostream&
Display(std::ostream& os)
const override;
645 double DoEvaluate(
double v)
const override;
654 const FormulaSubstitution& formula_subst)
override;
656 std::ostream&
Display(std::ostream& os)
const override;
659 double DoEvaluate(
double v)
const override;
668 const FormulaSubstitution& formula_subst)
override;
670 std::ostream&
Display(std::ostream& os)
const override;
673 double DoEvaluate(
double v)
const override;
682 const FormulaSubstitution& formula_subst)
override;
684 std::ostream&
Display(std::ostream& os)
const override;
690 static void check_domain(
double v);
691 double DoEvaluate(
double v)
const override;
700 const FormulaSubstitution& formula_subst)
override;
702 std::ostream&
Display(std::ostream& os)
const override;
708 static void check_domain(
double v);
709 double DoEvaluate(
double v)
const override;
718 const FormulaSubstitution& formula_subst)
override;
720 std::ostream&
Display(std::ostream& os)
const override;
723 double DoEvaluate(
double v)
const override;
733 const FormulaSubstitution& formula_subst)
override;
735 std::ostream&
Display(std::ostream& os)
const override;
738 double DoEvaluate(
double v1,
double v2)
const override;
747 const FormulaSubstitution& formula_subst)
override;
749 std::ostream&
Display(std::ostream& os)
const override;
752 double DoEvaluate(
double v)
const override;
761 const FormulaSubstitution& formula_subst)
override;
763 std::ostream&
Display(std::ostream& os)
const override;
766 double DoEvaluate(
double v)
const override;
775 const FormulaSubstitution& formula_subst)
override;
777 std::ostream&
Display(std::ostream& os)
const override;
780 double DoEvaluate(
double v)
const override;
789 const FormulaSubstitution& formula_subst)
override;
791 std::ostream&
Display(std::ostream& os)
const override;
794 double DoEvaluate(
double v1,
double v2)
const override;
803 const FormulaSubstitution& formula_subst)
override;
805 std::ostream&
Display(std::ostream& os)
const override;
808 double DoEvaluate(
double v1,
double v2)
const override;
823 const FormulaSubstitution& formula_subst)
override;
825 std::ostream&
Display(std::ostream& os)
const override;
856 const FormulaSubstitution& formula_subst)
override;
858 std::ostream&
Display(std::ostream& os)
const override;
861 const std::string&
get_name()
const {
return name_; }
864 const std::string name_;
Symbolic expression representing tangent function.
Definition: symbolic_expression_cell.h:663
Symbolic expression representing absolute value function.
Definition: symbolic_expression_cell.h:567
virtual bool EqualTo(const ExpressionCell &c) const =0
Checks structural equality.
Symbolic expression representing if-then-else expression.
Definition: symbolic_expression_cell.h:812
const Expression & get_else_expression() const
Returns the 'else' expression.
Definition: symbolic_expression_cell.h:832
Symbolic expression representing cosine function.
Definition: symbolic_expression_cell.h:649
Symbolic expression representing an uninterpreted function.
Definition: symbolic_expression_cell.h:845
Symbolic expression representing a multiplication of powers.
Definition: symbolic_expression_cell.h:426
const Expression & get_first_argument() const
Returns the first argument.
Definition: symbolic_expression_cell.h:175
Symbolic expression representing arctangent function.
Definition: symbolic_expression_cell.h:713
spdlog::logger * log()
Provide a global logger.
Definition: logging.cc:33
Represents the base class for unary expressions.
Definition: symbolic_expression_cell.h:130
const std::string & get_name() const
Returns the name of this expression.
Definition: symbolic_expression_cell.h:861
Symbolic expression representing a real constant represented by a double interval [lb...
Definition: symbolic_expression_cell.h:256
Sum type of symbolic::Expression and symbolic::Formula.
Definition: api.cc:9
double get_constant() const
Returns the constant.
Definition: symbolic_expression_cell.h:319
std::map< Expression, double > & get_mutable_expr_to_coeff_map()
Returns map from an expression to its coefficient.
Definition: symbolic_expression_cell.h:328
Symbolic expression representing a floating-point constant (double).
Definition: symbolic_expression_cell.h:233
Represents an abstract class which is the base of concrete symbolic-expression classes.
Definition: symbolic_expression_cell.h:26
Symbolic expression representing hyperbolic sine function.
Definition: symbolic_expression_cell.h:742
virtual bool Less(const ExpressionCell &c) const =0
Provides lexicographical ordering between expressions.
virtual std::ostream & Display(std::ostream &os) const =0
Outputs string representation of expression into output stream os.
Represents a symbolic variable.
Definition: symbolic_variable.h:16
size_t get_hash() const
Returns hash value.
Definition: symbolic_expression_cell.h:32
Symbolic expression representing hyperbolic cosine function.
Definition: symbolic_expression_cell.h:756
Symbolic expression representing hyperbolic tangent function.
Definition: symbolic_expression_cell.h:770
ExpressionCell & operator=(ExpressionCell &&e)=delete
Move-assigns (DELETED).
double get_constant() const
Returns constant term.
Definition: symbolic_expression_cell.h:440
const Expression & get_second_argument() const
Returns the second argument.
Definition: symbolic_expression_cell.h:177
Symbolic expression representing a variable.
Definition: symbolic_expression_cell.h:212
const std::map< Expression, double > & get_expr_to_coeff_map() const
Returns map from an expression to its coefficient.
Definition: symbolic_expression_cell.h:321
bool include_ite() const
Returns true if this symbolic expression includes an ITE (If-Then-Else) expression.
Definition: symbolic_expression_cell.h:48
virtual ~ExpressionCell()=default
Default destructor.
Symbolic expression representing square-root.
Definition: symbolic_expression_cell.h:598
Expression GetExpression()
Returns an expression pointing to this ExpressionCell.
Definition: symbolic_expression_cell.cc:246
Symbolic expression representing exponentiation using the base of natural logarithms.
Definition: symbolic_expression_cell.h:584
Factory class to help build ExpressionAdd expressions.
Definition: symbolic_expression_cell.h:348
const std::map< Expression, Expression > & get_base_to_exponent_map() const
Returns map from a term to its exponent.
Definition: symbolic_expression_cell.h:442
virtual Expression Differentiate(const Variable &x) const =0
Differentiates this symbolic expression with respect to the variable var.
ExpressionKind get_kind() const
Returns expression kind.
Definition: symbolic_expression_cell.h:29
Represents a symbolic environment (mapping from a variable to a value).
Definition: symbolic_environment.h:52
bool is_polynomial() const
Checks if this symbolic expression is convertible to Polynomial.
Definition: symbolic_expression_cell.h:44
const Formula & get_conditional_formula() const
Returns the conditional formula.
Definition: symbolic_expression_cell.h:828
Symbolic expression representing logarithms.
Definition: symbolic_expression_cell.h:549
Symbolic expression representing division.
Definition: symbolic_expression_cell.h:535
Symbolic expression representing sine function.
Definition: symbolic_expression_cell.h:635
Factory class to help build ExpressionMul expressions.
Definition: symbolic_expression_cell.h:470
virtual Expression Substitute(const ExpressionSubstitution &expr_subst, const FormulaSubstitution &formula_subst)=0
Returns an Expression obtained by replacing all occurrences of the variables in s in the current expr...
Symbolic expression representing an addition which is a sum of products.
Definition: symbolic_expression_cell.h:304
Symbolic expression representing min function.
Definition: symbolic_expression_cell.h:784
Symbolic expression representing arcsine function.
Definition: symbolic_expression_cell.h:677
Symbolic expression representing arccosine function.
Definition: symbolic_expression_cell.h:695
virtual double Evaluate(const Environment &env) const =0
Evaluates under a given environment (by default, an empty environment).
virtual Expression Expand()=0
Expands out products and positive integer powers in expression.
std::map< Expression, Expression > & get_mutable_base_to_exponent_map()
Returns map from a term to its exponent.
Definition: symbolic_expression_cell.h:449
Symbolic expression representing max function.
Definition: symbolic_expression_cell.h:798
Represents the base class for binary expressions.
Definition: symbolic_expression_cell.h:169
unsigned use_count() const
Returns the reference count of this cell.
Definition: symbolic_expression_cell.h:78
Symbolic expression representing atan2 function (arctangent function with two arguments).
Definition: symbolic_expression_cell.h:728
Represents a set of variables.
Definition: symbolic_variables.h:25
Represents a symbolic form of an expression.
Definition: symbolic_expression.h:164
Symbolic expression representing NaN (not-a-number).
Definition: symbolic_expression_cell.h:278
ExpressionCell()=delete
Default constructor (DELETED).
Symbolic expression representing power function.
Definition: symbolic_expression_cell.h:616
const Expression & get_then_expression() const
Returns the 'then' expression.
Definition: symbolic_expression_cell.h:830
const Variables & GetVariables() const
Collects variables in expression.
Definition: symbolic_expression_cell.cc:248
const Expression & get_argument() const
Returns the argument.
Definition: symbolic_expression_cell.h:136